syntax: bound markdownLinkText start lookahead to a single line - #231
Open
jvoisin wants to merge 1 commit into
Open
syntax: bound markdownLinkText start lookahead to a single line#231jvoisin wants to merge 1 commit into
jvoisin wants to merge 1 commit into
Conversation
The markdownLinkText region validates an opening '[' with a lookahead
that scans for a matching ']' followed by '[' or '('. Its inner
character classes used the multi-line form \_[^][], so an unmatched '['
made the lookahead scan forward across the rest of the buffer, both
dominating markdownLinkText cost on bracket-heavy files and bleeding
link highlighting onto following lines.
Make the three inner classes in the start lookahead single-line
([^][]). The end pattern is already single-line, so this only tightens
where a region may begin.
Inline, nested ([a [b] c](url)), reference ([text][ref]), and image
links classify identically. Multi-line link text (opening '[' and
closing ']' on different lines) is no longer highlighted; it is valid
CommonMark but uncommon, and this syntax's inline handling is otherwise
line-oriented. A stray unclosed '[' no longer bleeds onto later lines.
syntime (markdownLinkText total) on a 6000-line link-heavy corpus:
~0.0805s -> ~0.0617s (-23%).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The markdownLinkText region validates an opening '[' with a lookahead that scans for a matching ']' followed by '[' or '('. Its inner character classes used the multi-line form _[^][], so an unmatched '[' made the lookahead scan forward across the rest of the buffer, both dominating markdownLinkText cost on bracket-heavy files and bleeding link highlighting onto following lines.
Make the three inner classes in the start lookahead single-line ([^][]). The end pattern is already single-line, so this only tightens where a region may begin.
Inline, nested (a [b] c), reference ([text][ref]), and image links classify identically. Multi-line link text (opening '[' and closing ']' on different lines) is no longer highlighted; it is valid CommonMark but uncommon, and this syntax's inline handling is otherwise line-oriented. A stray unclosed '[' no longer bleeds onto later lines.
syntime (markdownLinkText total) on a 6000-line link-heavy corpus: ~0.0805s -> ~0.0617s (-23%).