From a42886d8ffac2ebcb3004584ea122fe81cf3abf2 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Wed, 7 Apr 2021 09:34:31 +0430 Subject: [PATCH] LibGUI: Update the autocomplete suggestions after processing keys Previously, this was updating the suggestions before processing the keys and whatever changes they caused, making the suggestions stale until the periodic auto-autocomplete timer fired (if enabled). --- Userland/Libraries/LibGUI/TextEditor.cpp | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index da002e0c11..56b6a8be54 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -779,26 +779,26 @@ void TextEditor::keydown_event(KeyEvent& event) return; } - } else if (is_multi_line()) { - ArmedScopeGuard update_autocomplete { [&] { - if (m_autocomplete_box && m_autocomplete_box->is_visible()) { - m_autocomplete_provider->provide_completions([&](auto completions) { - m_autocomplete_box->update_suggestions(move(completions)); - }); - } - } }; - - if (!event.shift() && !event.alt() && event.ctrl() && event.key() == KeyCode::Key_Space) { - if (m_autocomplete_provider) { - try_show_autocomplete(); - update_autocomplete.disarm(); - return; - } - } - } else { + } else if (!is_multi_line()) { VERIFY_NOT_REACHED(); } + ArmedScopeGuard update_autocomplete { [&] { + if (m_autocomplete_box && m_autocomplete_box->is_visible()) { + m_autocomplete_provider->provide_completions([&](auto completions) { + m_autocomplete_box->update_suggestions(move(completions)); + }); + } + } }; + + if (is_multi_line() && !event.shift() && !event.alt() && event.ctrl() && event.key() == KeyCode::Key_Space) { + if (m_autocomplete_provider) { + try_show_autocomplete(); + update_autocomplete.disarm(); + return; + } + } + if (m_editing_engine->on_key(event)) return;