summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorthislooksfun <tlf@thislooks.fun>2021-10-28 00:44:55 -0500
committerAndreas Kling <kling@serenityos.org>2021-11-02 17:53:22 +0100
commit6bd16cc309336c278ae3dd8008d29d8765eba499 (patch)
treef765204abf204b1b955abfe64a903ed49ca0a036 /Userland/Libraries/LibGUI
parent86ea41970df46ecb0de291b90b418b482aa692bd (diff)
downloadserenity-6bd16cc309336c278ae3dd8008d29d8765eba499.zip
LibGUI: Always pre-select the first autocomplete suggestion
Previously we would only pre-select the row the first time the box was shown, which is not ideal. Now we behave like other editors.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/AutocompleteProvider.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
index 280d19aefc..58ffcea628 100644
--- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
+++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
@@ -112,12 +112,13 @@ void AutocompleteBox::update_suggestions(Vector<AutocompleteProvider::Entry>&& s
model.set_suggestions(move(suggestions));
} else {
m_suggestion_view->set_model(adopt_ref(*new AutocompleteSuggestionModel(move(suggestions))));
- if (has_suggestions)
- m_suggestion_view->set_cursor(m_suggestion_view->model()->index(0), GUI::AbstractView::SelectionUpdate::Set);
}
m_suggestion_view->model()->invalidate();
+ if (has_suggestions)
+ m_suggestion_view->set_cursor(m_suggestion_view->model()->index(0), GUI::AbstractView::SelectionUpdate::Set);
+
m_suggestion_view->set_visible(has_suggestions);
m_no_suggestions_view->set_visible(!has_suggestions);
m_popup_window->resize(has_suggestions ? Gfx::IntSize(300, 100) : Gfx::IntSize(175, 25));
@@ -136,8 +137,6 @@ void AutocompleteBox::show(Gfx::IntPoint suggestion_box_location)
return;
m_popup_window->move_to(suggestion_box_location);
- if (!is_visible())
- m_suggestion_view->move_cursor(GUI::AbstractView::CursorMovement::Home, GUI::AbstractTableView::SelectionUpdate::Set);
m_popup_window->show();
}