summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/AbstractView.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-29 00:43:50 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-29 00:43:50 +0100
commitf06b240ce0265ba121a5e41b4319cad1a666e53d (patch)
tree497e9801fdb06c24af59abc60aa31a60df5da47b /Libraries/LibGUI/AbstractView.cpp
parent66c0374fd72f299c8f0e9a0ffdfa2f05d7919969 (diff)
downloadserenity-f06b240ce0265ba121a5e41b4319cad1a666e53d.zip
LibGUI: Enforce the SelectionMode in AbstractView::set_cursor()
Diffstat (limited to 'Libraries/LibGUI/AbstractView.cpp')
-rw-r--r--Libraries/LibGUI/AbstractView.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp
index 4bceeb3028..8a4f0618fd 100644
--- a/Libraries/LibGUI/AbstractView.cpp
+++ b/Libraries/LibGUI/AbstractView.cpp
@@ -433,7 +433,7 @@ void AbstractView::set_key_column_and_sort_order(int column, SortOrder sort_orde
void AbstractView::set_cursor(ModelIndex index, SelectionUpdate selection_update, bool scroll_cursor_into_view)
{
- if (!model() || !index.is_valid()) {
+ if (!model() || !index.is_valid() || selection_mode() == SelectionMode::NoSelection) {
m_cursor_index = {};
cancel_searching();
return;
@@ -442,6 +442,9 @@ void AbstractView::set_cursor(ModelIndex index, SelectionUpdate selection_update
if (!m_cursor_index.is_valid() || model()->parent_index(m_cursor_index) != model()->parent_index(index))
cancel_searching();
+ if (selection_mode() == SelectionMode::SingleSelection && (selection_update == SelectionUpdate::Ctrl || selection_update == SelectionUpdate::Shift))
+ selection_update = SelectionUpdate::Set;
+
if (model()->is_valid(index)) {
if (selection_update == SelectionUpdate::Set)
set_selection(index);