mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibCpp: Fix off-by-one error in SyntaxHighlighter
This changes the C++ SyntaxHighlighter to conform to the now-fixed rendering of syntax highlighting spans in GUI::TextEditor. Contrary to other syntax highlighters, for this one the change has been made to the SyntaxHighlighter rather than the Lexer. This is due to the fact that the Parser also uses the same Lexer. I'm soure there is some more elegant way to do this, but this patch at least unbreaks the C++ syntax highlighting.
This commit is contained in:
parent
617c54a00b
commit
ec2f0fc8eb
Notes:
sideshowbarker
2024-07-18 16:52:37 +09:00
Author: https://github.com/MaxWipfli Commit: https://github.com/SerenityOS/serenity/commit/ec2f0fc8eb7 Pull-request: https://github.com/SerenityOS/serenity/pull/7768 Issue: https://github.com/SerenityOS/serenity/issues/7349 Reviewed-by: https://github.com/alimpfard
1 changed files with 3 additions and 2 deletions
|
@ -63,10 +63,11 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
|
|||
|
||||
Vector<GUI::TextDocumentSpan> spans;
|
||||
for (auto& token : tokens) {
|
||||
dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "{} @ {}:{} - {}:{}", token.type_as_string(), token.start().line, token.start().column, token.end().line, token.end().column);
|
||||
// FIXME: The +1 for the token end column is a quick hack due to not wanting to modify the lexer (which is also used by the parser). Maybe there's a better way to do this.
|
||||
dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "{} @ {}:{} - {}:{}", token.type_as_string(), token.start().line, token.start().column, token.end().line, token.end().column + 1);
|
||||
GUI::TextDocumentSpan span;
|
||||
span.range.set_start({ token.start().line, token.start().column });
|
||||
span.range.set_end({ token.end().line, token.end().column });
|
||||
span.range.set_end({ token.end().line, token.end().column + 1 });
|
||||
auto style = style_for_token_type(palette, token.type());
|
||||
span.attributes.color = style.color;
|
||||
span.attributes.bold = style.bold;
|
||||
|
|
Loading…
Reference in a new issue