1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 13:47:35 +00:00

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).
This commit is contained in:
AnotherTest 2021-04-07 09:34:31 +04:30 committed by Andreas Kling
parent d215578f55
commit a42886d8ff

View file

@ -779,7 +779,10 @@ void TextEditor::keydown_event(KeyEvent& event)
return; return;
} }
} else if (is_multi_line()) { } else if (!is_multi_line()) {
VERIFY_NOT_REACHED();
}
ArmedScopeGuard update_autocomplete { [&] { ArmedScopeGuard update_autocomplete { [&] {
if (m_autocomplete_box && m_autocomplete_box->is_visible()) { if (m_autocomplete_box && m_autocomplete_box->is_visible()) {
m_autocomplete_provider->provide_completions([&](auto completions) { m_autocomplete_provider->provide_completions([&](auto completions) {
@ -788,16 +791,13 @@ void TextEditor::keydown_event(KeyEvent& event)
} }
} }; } };
if (!event.shift() && !event.alt() && event.ctrl() && event.key() == KeyCode::Key_Space) { if (is_multi_line() && !event.shift() && !event.alt() && event.ctrl() && event.key() == KeyCode::Key_Space) {
if (m_autocomplete_provider) { if (m_autocomplete_provider) {
try_show_autocomplete(); try_show_autocomplete();
update_autocomplete.disarm(); update_autocomplete.disarm();
return; return;
} }
} }
} else {
VERIFY_NOT_REACHED();
}
if (m_editing_engine->on_key(event)) if (m_editing_engine->on_key(event))
return; return;