Skip to content

lexer: fixed syntax highlighting breaks on longer files - #1357

Open
jorbakk wants to merge 1 commit into
martanne:masterfrom
jorbakk:lex_string
Open

lexer: fixed syntax highlighting breaks on longer files#1357
jorbakk wants to merge 1 commit into
martanne:masterfrom
jorbakk:lex_string

Conversation

@jorbakk

@jorbakk jorbakk commented May 28, 2026

Copy link
Copy Markdown
Contributor

If lexer starts parsing at a file offset determined by the horizon variable and this offset happens to be within a string, then all non-strings are highlighted as strings and vice versa.

This only occurs with strings that are delimited symmetrically, e.g. single and double quotes. It doesn't affect other syntactic delimiters that are non-symmetric, e.g. parentheses.

With this patch, if the horizon variable is set to -1, the whole file buffer is run through the lexer. Performance is still reasonably good, as no syntax highlighting takes place outside of the viewport.

Fixes issue #1253

If lexer starts parsing at a file offset determined by the horizon variable
and this offset happens to be within a string, then all non-strings are
highlighted as strings and vice versa.

This only occurs with strings that are delimited symmetrically, e.g.
single and double quotes. It doesn't affect other syntactic delimiters that are
non-symmetric, e.g. parentheses.

With this patch, if the horizon variable is set to -1, the whole file buffer
is run through the lexer. Performance is still reasonably good, as no syntax
highlighting takes place outside of the viewport.

Fixes issue martanne#1253
@jorbakk

jorbakk commented May 31, 2026 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant