From b05af48d80a3d30053c7f381e3bbc5d2517a8865 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Sun, 6 Mar 2022 10:32:15 +0330 Subject: [PATCH] js: Use token offset for highlighting instead of column offset This makes it work correctly with multiline inputs as well. --- Userland/Utilities/js.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 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) {