1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +00:00

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.
This commit is contained in:
thislooksfun 2021-10-28 00:44:55 -05:00 committed by Andreas Kling
parent 86ea41970d
commit 6bd16cc309

View file

@ -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();
}