diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2022-03-06 10:32:15 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-06 13:20:41 +0100 |
commit | b05af48d80a3d30053c7f381e3bbc5d2517a8865 (patch) | |
tree | 4d0a1e53b1039691a538754ec4cb57a07cb2258c /Userland/Utilities/js.cpp | |
parent | 287f33165e84b212ada2e572e92b7adb6a56a370 (diff) | |
download | serenity-b05af48d80a3d30053c7f381e3bbc5d2517a8865.zip |
js: Use token offset for highlighting instead of column offset
This makes it work correctly with multiline inputs as well.
Diffstat (limited to 'Userland/Utilities/js.cpp')
-rw-r--r-- | Userland/Utilities/js.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 8eb75c6f97..fe570e4a50 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -1451,7 +1451,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) bool indenters_starting_line = true; for (JS::Token token = lexer.next(); token.type() != JS::TokenType::Eof; token = lexer.next()) { auto length = Utf8View { token.value() }.length(); - auto start = token.line_column() - 1; + auto start = token.offset(); auto end = start + length; if (indenters_starting_line) { if (token.type() != JS::TokenType::ParenClose && token.type() != JS::TokenType::BracketClose && token.type() != JS::TokenType::CurlyClose) { |