1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +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,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;