Browse Source

js: Use token offset for highlighting instead of column offset

This makes it work correctly with multiline inputs as well.
Ali Mohammad Pur 3 năm trước cách đây
mục cha
commit
b05af48d80
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      Userland/Utilities/js.cpp

+ 1 - 1
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) {