summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2022-11-17 10:40:52 -0500
committerAndreas Kling <kling@serenityos.org>2022-11-19 16:04:42 +0100
commit901878bad966a64d098e35ec29cbd2a66cfab0f2 (patch)
treed05b316927bccd9b455398b89bc55d0ba13f7f26 /Userland/Libraries/LibGUI
parent2c5890293996d6e369961be8c0419d1d6eec2f6b (diff)
downloadserenity-901878bad966a64d098e35ec29cbd2a66cfab0f2.zip
LibGUI: Use move_cursor() API for AutocompleteProvider
Fixes failure to update focus rect when moving between items.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/AutocompleteProvider.cpp22
1 files changed, 2 insertions, 20 deletions
diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
index 93136aaca2..0be4c90c5f 100644
--- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
+++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp
@@ -160,30 +160,12 @@ void AutocompleteBox::close()
void AutocompleteBox::next_suggestion()
{
- GUI::ModelIndex new_index = m_suggestion_view->selection().first();
- 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);
- }
+ m_suggestion_view->move_cursor(GUI::AbstractView::CursorMovement::Down, GUI::AbstractView::SelectionUpdate::Set);
}
void AutocompleteBox::previous_suggestion()
{
- GUI::ModelIndex new_index = m_suggestion_view->selection().first();
- 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);
- }
+ m_suggestion_view->move_cursor(GUI::AbstractView::CursorMovement::Up, GUI::AbstractView::SelectionUpdate::Set);
}
CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying AutocompleteBox::apply_suggestion()