LibGUI: Fix text wrap artifact when selecting text

The issue was caused by the usage of the
selection_end_column_within_line variable as if it was the visual line.
This is fixed by taking the minimum between this value and the length of
a visual line.
This commit is contained in:
Lucas CHOLLET 2022-04-24 18:26:34 +02:00 committed by Andreas Kling
parent 559ea5a030
commit 881f499704
Notes: sideshowbarker 2024-07-17 11:33:31 +09:00

View file

@ -686,8 +686,8 @@ void TextEditor::paint_event(PaintEvent& event)
}
if (physical_line_has_selection && window()->focused_widget() == this) {
size_t start_of_selection_within_visual_line = (size_t)max(0, (int)selection_start_column_within_line - (int)start_of_visual_line);
size_t end_of_selection_within_visual_line = selection_end_column_within_line - start_of_visual_line;
size_t const start_of_selection_within_visual_line = (size_t)max(0, (int)selection_start_column_within_line - (int)start_of_visual_line);
size_t const end_of_selection_within_visual_line = min(selection_end_column_within_line - start_of_visual_line, visual_line_text.length());
bool current_visual_line_has_selection = start_of_selection_within_visual_line != end_of_selection_within_visual_line
&& ((line_index != selection.start().line() && line_index != selection.end().line())