mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibGUI: Fix TextEditor crashing when selecting a blank line
Previously, the TextEditor would crash when selecting a line with no codepoints due to a null dereference, so this patch makes sure there is actually any text to render before giving it to the painter.
This commit is contained in:
parent
2a241a11bb
commit
b0b03c52af
Notes:
sideshowbarker
2024-07-19 05:59:18 +09:00
Author: https://github.com/FalseHonesty Commit: https://github.com/SerenityOS/serenity/commit/b0b03c52af2 Pull-request: https://github.com/SerenityOS/serenity/pull/2444
@ -498,12 +498,14 @@ void TextEditor::paint_event(PaintEvent& event)
|
||||
|
||||
painter.fill_rect(selection_rect, background_color);
|
||||
|
||||
Utf32View visual_selected_text {
|
||||
visual_line_text.codepoints() + start_of_selection_within_visual_line,
|
||||
end_of_selection_within_visual_line - start_of_selection_within_visual_line
|
||||
};
|
||||
if (visual_line_text.codepoints()) {
|
||||
Utf32View visual_selected_text {
|
||||
visual_line_text.codepoints() + start_of_selection_within_visual_line,
|
||||
end_of_selection_within_visual_line - start_of_selection_within_visual_line
|
||||
};
|
||||
|
||||
painter.draw_text(selection_rect, visual_selected_text, Gfx::TextAlignment::CenterLeft, text_color);
|
||||
painter.draw_text(selection_rect, visual_selected_text, Gfx::TextAlignment::CenterLeft, text_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
++visual_line_index;
|
||||
|
Loading…
Reference in New Issue
Block a user