summaryrefslogtreecommitdiff
path: root/Userland/Utilities/js.cpp
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-03-06 10:32:15 +0330
committerAndreas Kling <kling@serenityos.org>2022-03-06 13:20:41 +0100
commitb05af48d80a3d30053c7f381e3bbc5d2517a8865 (patch)
tree4d0a1e53b1039691a538754ec4cb57a07cb2258c /Userland/Utilities/js.cpp
parent287f33165e84b212ada2e572e92b7adb6a56a370 (diff)
downloadserenity-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.cpp2
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) {