mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
LibWebView: Append remaining source after consuming all tokens
Since "Character" tokens do not have an "end position", viewing source drops the source contents following the final non-"Character" token. By handling the EOF token and breaking out of the loop, we avoid this issue.
This commit is contained in:
parent
d220cf3abd
commit
7de669dc07
Notes:
sideshowbarker
2024-07-16 23:08:48 +09:00
Author: https://github.com/sgeisenh Commit: https://github.com/LadybirdBrowser/ladybird/commit/7de669dc07 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/353 Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 3 additions and 1 deletions
|
@ -60,7 +60,7 @@ String highlight_source(URL::URL const& url, StringView source)
|
|||
previous_position = end_position;
|
||||
};
|
||||
|
||||
for (auto token = tokenizer.next_token(); token.has_value() && !token->is_end_of_file(); token = tokenizer.next_token()) {
|
||||
for (auto token = tokenizer.next_token(); token.has_value(); token = tokenizer.next_token()) {
|
||||
if (token->is_comment()) {
|
||||
append_source(token->start_position().byte_offset);
|
||||
append_source(token->end_position().byte_offset, "comment"sv);
|
||||
|
@ -83,6 +83,8 @@ String highlight_source(URL::URL const& url, StringView source)
|
|||
append_source(token->end_position().byte_offset);
|
||||
} else {
|
||||
append_source(token->end_position().byte_offset);
|
||||
if (token->is_end_of_file())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue