1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00

LibGUI: Allow autocomplete to stay open after applying

Previously the autocomplete box would always close after applying a
suggestion. This is the desired behavior in almost all cases, but there
are some situations (like autocompleting paths) where it would be nicer
to keep the autocomplete box open after applying the suggestion.
This commit is contained in:
thislooksfun 2021-10-28 20:31:54 -05:00 committed by Andreas Kling
parent 352f593958
commit d5baf1c1fa
4 changed files with 33 additions and 8 deletions

View file

@ -739,8 +739,11 @@ void TextEditor::select_all()
void TextEditor::keydown_event(KeyEvent& event)
{
if (m_autocomplete_box && m_autocomplete_box->is_visible() && (event.key() == KeyCode::Key_Return || event.key() == KeyCode::Key_Tab)) {
m_autocomplete_box->apply_suggestion();
hide_autocomplete();
TemporaryChange change { m_should_keep_autocomplete_box, true };
if (m_autocomplete_box->apply_suggestion() == AutocompleteProvider::Entry::HideAutocompleteAfterApplying::Yes)
hide_autocomplete();
else
try_update_autocomplete();
return;
}