LibWebView: Stop tokenizing the source HTML once we hit an EOF token

This commit is contained in:
Timothy Flynn
2024-03-23 10:06:09 -04:00
committed by Andreas Kling
parent 26a516c85f
commit 775282f9fc

View File

@@ -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 = tokenizer.next_token()) {
for (auto token = tokenizer.next_token(); token.has_value() && !token->is_end_of_file(); token = tokenizer.next_token()) {
if (token->is_comment()) {
append_source(token->start_position().byte_offset);
append_source(token->end_position().byte_offset, "comment"sv);