From 6bd16cc309336c278ae3dd8008d29d8765eba499 Mon Sep 17 00:00:00 2001 From: thislooksfun Date: Thu, 28 Oct 2021 00:44:55 -0500 Subject: [PATCH] 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. --- Userland/Libraries/LibGUI/AutocompleteProvider.cpp | 7 +++---- 1 file 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&& 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(); }