LibJS: Fix off-by-one error in SyntaxHighlighter

This changes the JS syntax highlighter to conform to the now-fixed
rendering of syntax highlighting spans in GUI::TextEditor.
This commit is contained in:
Max Wipfli 2021-06-03 23:55:16 +02:00 committed by Ali Mohammad Pur
parent a819f98956
commit 106ad6ba09
Notes: sideshowbarker 2024-07-18 16:53:28 +09:00

View file

@ -72,7 +72,7 @@ void SyntaxHighlighter::rehighlight(const Palette& palette)
return;
start = position;
for (size_t i = 0; i < str.length() - 1; ++i)
for (size_t i = 0; i < str.length(); ++i)
advance_position(str[i]);
GUI::TextDocumentSpan span;
@ -85,7 +85,6 @@ void SyntaxHighlighter::rehighlight(const Palette& palette)
span.is_skippable = is_trivia;
span.data = reinterpret_cast<void*>(static_cast<size_t>(type));
spans.append(span);
advance_position(str[str.length() - 1]);
dbgln_if(SYNTAX_HIGHLIGHTING_DEBUG, "{}{} @ '{}' {}:{} - {}:{}",
token.name(),