mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:27:35 +00:00
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.
This commit is contained in:
parent
db886fe18b
commit
e8b7bdbd57
1 changed files with 4 additions and 10 deletions
|
@ -585,6 +585,10 @@ void TextEditor::paint_event(PaintEvent& event)
|
||||||
};
|
};
|
||||||
while (span_index < document().spans().size()) {
|
while (span_index < document().spans().size()) {
|
||||||
auto& span = document().spans()[span_index];
|
auto& span = document().spans()[span_index];
|
||||||
|
if (span.range.end().line() < line_index) {
|
||||||
|
++span_index;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (span.range.start().line() > line_index
|
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())) {
|
|| (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
|
// 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()) {
|
if (next_column < visual_line_text.length()) {
|
||||||
draw_text_helper(next_column, visual_line_text.length(), unspanned_font, { unspanned_color });
|
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()) {
|
if (m_visualize_trailing_whitespace && line.ends_in_whitespace()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue