summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorMatteo Benetti <matteo.benetti@proton.me>2023-04-13 14:44:41 +0200
committerAndreas Kling <kling@serenityos.org>2023-04-14 10:00:52 +0200
commit3e1626acdcf6088d65610ff8bfed07b92420a0de (patch)
treed8566e899f891bf8a467de56694a8784a1117aab /Userland/Libraries/LibGUI
parentfb47b988ca379433e353a503dbfdddcaa5e3c67f (diff)
downloadserenity-3e1626acdcf6088d65610ff8bfed07b92420a0de.zip
Spreadsheet+LibSyntax: Never insert spans directly
Function `CellSyntaxHighlighter::rehighlight()` direct inserted spans to TextDocument `m_span` vector missing out important reordering and merging operation carried out by `TextDocument::set_spans()`. This caused overlapping spans for a cell with only a `=` symbol (one for the actual token and one for the highlighting) to miscalculate `start` and `end` value and a `length` value (of `size_t` type) with a `0-1` substraction (result: 18446744073709551615) causing `Utf32View::substring_view()` to fail the `!Checked<size_t>::addition_would_overflow(offset, length)` assertion This remove the possibility to directly alter `TextDocument`'s spans thus forcing the utilization of `HighlighterClient::do_set_spans()` interface function. Proper refactor have been applied to `CellSyntaxHighlighter::rehighlight()` function
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.h1
1 files changed, 0 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h
index dfabda73cb..55ddc8946a 100644
--- a/Userland/Libraries/LibGUI/TextEditor.h
+++ b/Userland/Libraries/LibGUI/TextEditor.h
@@ -306,7 +306,6 @@ private:
virtual void document_did_update_undo_stack() override;
// ^Syntax::HighlighterClient
- virtual Vector<TextDocumentSpan>& spans() final { return document().spans(); }
virtual Vector<TextDocumentSpan> const& spans() const final { return document().spans(); }
virtual void set_span_at_index(size_t index, TextDocumentSpan span) final { document().set_span_at_index(index, move(span)); }
virtual Vector<GUI::TextDocumentFoldingRegion>& folding_regions() final { return document().folding_regions(); };