mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +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:
parent
86ea41970d
commit
6bd16cc309
1 changed files with 3 additions and 4 deletions
|
@ -112,12 +112,13 @@ void AutocompleteBox::update_suggestions(Vector<AutocompleteProvider::Entry>&& s
|
||||||
model.set_suggestions(move(suggestions));
|
model.set_suggestions(move(suggestions));
|
||||||
} else {
|
} else {
|
||||||
m_suggestion_view->set_model(adopt_ref(*new AutocompleteSuggestionModel(move(suggestions))));
|
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();
|
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_suggestion_view->set_visible(has_suggestions);
|
||||||
m_no_suggestions_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));
|
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;
|
return;
|
||||||
|
|
||||||
m_popup_window->move_to(suggestion_box_location);
|
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();
|
m_popup_window->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue