From 79a5a1c209ef98e128f2aac40511fa46315a0705 Mon Sep 17 00:00:00 2001 From: "Matthew B. Jones" Date: Sun, 7 Aug 2022 11:29:01 -0600 Subject: [PATCH] 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. --- Userland/Libraries/LibGUI/AbstractView.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGUI/AbstractView.cpp b/Userland/Libraries/LibGUI/AbstractView.cpp index 9785c54751..1c24d09583 100644 --- a/Userland/Libraries/LibGUI/AbstractView.cpp +++ b/Userland/Libraries/LibGUI/AbstractView.cpp @@ -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;