mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
LibGUI: Handle some edge cases in the spanned text drawing algorithm
This commit makes it skip invalid ranges and whine about overlapping spans before ignoring them (instead of crashing).
This commit is contained in:
parent
2089b24ab5
commit
0d17cf121c
1 changed files with 9 additions and 0 deletions
|
@ -531,6 +531,10 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
break;
|
||||
}
|
||||
auto& span = document().spans()[span_index];
|
||||
if (!span.range.is_valid()) {
|
||||
++span_index;
|
||||
continue;
|
||||
}
|
||||
if (span.range.end().line() < line_index) {
|
||||
dbgln("spans not sorted (span end {}:{} is before current line {}) => ignoring", span.range.end().line(), span.range.end().column(), line_index);
|
||||
++span_index;
|
||||
|
@ -562,6 +566,11 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
} else {
|
||||
span_start = span.range.start().column() - start_of_visual_line;
|
||||
}
|
||||
if (span_start < next_column) {
|
||||
dbgln("span started before the current position, maybe two spans overlap? (span start {} is before current position {}) => ignoring", span_start, next_column);
|
||||
++span_index;
|
||||
continue;
|
||||
}
|
||||
size_t span_end;
|
||||
bool span_consumned;
|
||||
if (span.range.end().line() > line_index || span.range.end().column() >= start_of_visual_line + visual_line_text.length()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue