summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorMatthew B. Jones <matthewbjones85@gmail.com>2022-08-07 11:29:01 -0600
committerBrian Gianforcaro <b.gianfo@gmail.com>2022-08-08 16:41:36 -0400
commit79a5a1c209ef98e128f2aac40511fa46315a0705 (patch)
tree0600df5e882bbde31bd1096fcf6ef4138967b730 /Userland/Libraries
parentff6f56ef7a84a9013412fcab3982415b0b48ceda (diff)
downloadserenity-79a5a1c209ef98e128f2aac40511fa46315a0705.zip
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.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibGUI/AbstractView.cpp3
1 files changed, 1 insertions, 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;