Browse Source

LibSQL: Fix off-by-one error in SyntaxHighlighter

This changes the SQL SyntaxHighlighter to conform to the now-fixed
rendering of syntax highlighting spans in GUI::TextEditor.
Max Wipfli 4 years ago
parent
commit
04897f6842
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Userland/Libraries/LibSQL/SyntaxHighlighter.cpp

+ 2 - 2
Userland/Libraries/LibSQL/SyntaxHighlighter.cpp

@@ -52,8 +52,8 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
             return;
 
         GUI::TextPosition position { token.line_number() - 1, token.line_column() - 1 };
-        for (size_t i = 0; i < str.length() - 1; ++i) {
-            if (str[i] == '\n') {
+        for (char c : str) {
+            if (c == '\n') {
                 position.set_line(position.line() + 1);
                 position.set_column(0);
             } else