summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2023-02-21 12:41:15 +0000
committerAndreas Kling <kling@serenityos.org>2023-02-28 13:23:55 +0100
commite8b7bdbd57e9486459c7ad10ee608c0d4942a082 (patch)
tree0734c7119cd74c73b8580043e7704a97947846fd /Userland
parentdb886fe18bad881c1e1064780937c75e92e52b5f (diff)
downloadserenity-e8b7bdbd57e9486459c7ad10ee608c0d4942a082.zip
LibGUI: Skip painting TextEditor spans that end on previous lines
This only becomes a problem with folding, since arbitrary lines may be invisible, meaning we try to apply a span for an invisible line N, on line N+X instead, causing occasional crashes. This check means we can remove the loop that skips spans occurring at the end of the line.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp
index e3619f01c6..b583d46565 100644
--- a/Userland/Libraries/LibGUI/TextEditor.cpp
+++ b/Userland/Libraries/LibGUI/TextEditor.cpp
@@ -585,6 +585,10 @@ void TextEditor::paint_event(PaintEvent& event)
};
while (span_index < document().spans().size()) {
auto& span = document().spans()[span_index];
+ if (span.range.end().line() < line_index) {
+ ++span_index;
+ continue;
+ }
if (span.range.start().line() > line_index
|| (span.range.start().line() == line_index && span.range.start().column() >= start_of_visual_line + visual_line_text.length())) {
// no more spans in this line, moving on
@@ -624,16 +628,6 @@ void TextEditor::paint_event(PaintEvent& event)
if (next_column < visual_line_text.length()) {
draw_text_helper(next_column, visual_line_text.length(), unspanned_font, { unspanned_color });
}
- // consume all spans that should end this line
- // this is necessary since the spans can include the new line character
- while (is_last_visual_line && span_index < document().spans().size()) {
- auto& span = document().spans()[span_index];
- if (span.range.end().line() == line_index) {
- ++span_index;
- } else {
- break;
- }
- }
}
if (m_visualize_trailing_whitespace && line.ends_in_whitespace()) {