|
@@ -59,21 +59,21 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
|
|
Syntax::TextPosition position { 0, 0 };
|
|
Syntax::TextPosition position { 0, 0 };
|
|
Syntax::TextPosition start { 0, 0 };
|
|
Syntax::TextPosition start { 0, 0 };
|
|
|
|
|
|
- auto advance_position = [&position](char ch) {
|
|
|
|
- if (ch == '\n') {
|
|
|
|
|
|
+ auto advance_position = [&position](u32 code_point) {
|
|
|
|
+ if (code_point == '\n') {
|
|
position.set_line(position.line() + 1);
|
|
position.set_line(position.line() + 1);
|
|
position.set_column(0);
|
|
position.set_column(0);
|
|
} else
|
|
} else
|
|
position.set_column(position.column() + 1);
|
|
position.set_column(position.column() + 1);
|
|
};
|
|
};
|
|
|
|
|
|
- auto append_token = [&](StringView str, Token const& token, bool is_trivia) {
|
|
|
|
|
|
+ auto append_token = [&](Utf8View str, Token const& token, bool is_trivia) {
|
|
if (str.is_empty())
|
|
if (str.is_empty())
|
|
return;
|
|
return;
|
|
|
|
|
|
start = position;
|
|
start = position;
|
|
- for (size_t i = 0; i < str.length(); ++i)
|
|
|
|
- advance_position(str[i]);
|
|
|
|
|
|
+ for (auto code_point : str)
|
|
|
|
+ advance_position(code_point);
|
|
|
|
|
|
Syntax::TextDocumentSpan span;
|
|
Syntax::TextDocumentSpan span;
|
|
span.range.set_start(start);
|
|
span.range.set_start(start);
|
|
@@ -100,10 +100,10 @@ void SyntaxHighlighter::rehighlight(Palette const& palette)
|
|
|
|
|
|
bool was_eof = false;
|
|
bool was_eof = false;
|
|
for (auto token = lexer.next(); !was_eof; token = lexer.next()) {
|
|
for (auto token = lexer.next(); !was_eof; token = lexer.next()) {
|
|
- append_token(token.trivia(), token, true);
|
|
|
|
|
|
+ append_token(Utf8View(token.trivia()), token, true);
|
|
|
|
|
|
auto token_start_position = position;
|
|
auto token_start_position = position;
|
|
- append_token(token.value(), token, false);
|
|
|
|
|
|
+ append_token(Utf8View(token.value()), token, false);
|
|
|
|
|
|
if (token.type() == TokenType::Eof)
|
|
if (token.type() == TokenType::Eof)
|
|
was_eof = true;
|
|
was_eof = true;
|