mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:48:11 +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
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…
Add table
Add a link
Reference in a new issue