Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lexer/rest.lua wrong handling of multiple line comments #107

Open
mcepl opened this issue Feb 14, 2024 · 1 comment
Open

lexer/rest.lua wrong handling of multiple line comments #107

mcepl opened this issue Feb 14, 2024 · 1 comment

Comments

@mcepl
Copy link

mcepl commented Feb 14, 2024

Talking about rST files, this is a wrong highlighting of a “commented out” paragraph.

screenshot-2023-11-02_22-11-1698961336

@orbitalquark
Copy link
Owner

Thanks for the report. The reST lexer really needs a refactor, and I'm not even sure significant newlines can be lexed properly since Scintillua doesn't always backtrack over newlines.

Does the following diff work for you? If it does, I can commit it. It doesn't work for me, but I'm using a GUI editor that typically starts lexing on newlines and doesn't always lex chunks as you'd expect.

--- lexers/lexer.lua
+++ lexers/lexer.lua
@@ -111,11 +111,11 @@
 lex:add_style('substitution', lexer.styles.variable)
 
 -- Comments.
 local line_comment = lexer.to_eol(prefix)
 local bprefix = any_indent * '..'
 local block_comment = bprefix * lexer.newline * indented_block
-lex:add_rule('comment', #bprefix * token(lexer.COMMENT, starts_line(line_comment + block_comment)))
+lex:add_rule('comment', #bprefix * token(lexer.COMMENT, starts_line(block_comment + line_comment)))
 
 -- Section titles (2 or more characters).
 local adornment_chars = lpeg.C(S('!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'))
 local adornment = lpeg.C(adornment_chars^2 * any_indent) * (lexer.newline + -1)

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

No branches or pull requests

2 participants