1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 23:27:42 +00:00

js: Use token offset for highlighting instead of column offset

This makes it work correctly with multiline inputs as well.
This commit is contained in:
Ali Mohammad Pur 2022-03-06 10:32:15 +03:30 committed by Andreas Kling
parent 287f33165e
commit b05af48d80

View file

@ -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) {