LibGUI: Use move_cursor() API for AutocompleteProvider

Fixes failure to update focus rect when moving between items.
This commit is contained in:
thankyouverycool 2022-11-17 10:40:52 -05:00 committed by Andreas Kling
parent 2c58902939
commit 901878bad9
Notes: sideshowbarker 2024-07-17 04:19:09 +09:00

View File

@ -160,30 +160,12 @@ void AutocompleteBox::close()
void AutocompleteBox::next_suggestion() void AutocompleteBox::next_suggestion()
{ {
GUI::ModelIndex new_index = m_suggestion_view->selection().first(); m_suggestion_view->move_cursor(GUI::AbstractView::CursorMovement::Down, GUI::AbstractView::SelectionUpdate::Set);
if (new_index.is_valid())
new_index = m_suggestion_view->model()->index(new_index.row() + 1);
else
new_index = m_suggestion_view->model()->index(0);
if (m_suggestion_view->model()->is_within_range(new_index)) {
m_suggestion_view->selection().set(new_index);
m_suggestion_view->scroll_into_view(new_index, Orientation::Vertical);
}
} }
void AutocompleteBox::previous_suggestion() void AutocompleteBox::previous_suggestion()
{ {
GUI::ModelIndex new_index = m_suggestion_view->selection().first(); m_suggestion_view->move_cursor(GUI::AbstractView::CursorMovement::Up, GUI::AbstractView::SelectionUpdate::Set);
if (new_index.is_valid())
new_index = m_suggestion_view->model()->index(new_index.row() - 1);
else
new_index = m_suggestion_view->model()->index(0);
if (m_suggestion_view->model()->is_within_range(new_index)) {
m_suggestion_view->selection().set(new_index);
m_suggestion_view->scroll_into_view(new_index, Orientation::Vertical);
}
} }
CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying AutocompleteBox::apply_suggestion() CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying AutocompleteBox::apply_suggestion()