LibGUI: Correct cursor index during mouseup_event

Previously, during a m_might_drag mouse_up event, we were updating
the selection directly, which caused the selection to be accurate
but the location of the cursor index to be stale/incorrect. The
side effect of this is then future events may point to the wrong
index.

Instead, call the set_cursor function with SelectionUpdate::Set,
which handles both updating the cursor index as well as the
selection index.
This commit is contained in:
Matthew B. Jones 2022-08-07 11:29:01 -06:00 committed by Brian Gianforcaro
parent ff6f56ef7a
commit 79a5a1c209

View file

@ -359,8 +359,7 @@ void AbstractView::mouseup_event(MouseEvent& event)
// Since we're here, it was not that; so fix up the selection now.
auto index = index_at_event_position(event.position());
if (index.is_valid()) {
set_selection(index);
set_selection_start_index(index);
set_cursor(index, SelectionUpdate::Set, true);
} else
clear_selection();
m_might_drag = false;