LibGUI: Stop the automatic autocomplete timer when typing whitespace

There's no reason to bring up autocomplete when the user is just
inserting indentation and spaces and such.
This commit is contained in:
AnotherTest 2021-01-03 02:58:29 +03:30 committed by Andreas Kling
commit 432c37cafc
Notes: sideshowbarker 2024-07-19 00:11:01 +09:00

View file

@ -1049,8 +1049,12 @@ void TextEditor::keydown_event(KeyEvent& event)
StringBuilder sb;
sb.append_code_point(event.code_point());
if (should_autocomplete_automatically())
m_autocomplete_timer->start();
if (should_autocomplete_automatically()) {
if (sb.string_view().is_whitespace())
m_autocomplete_timer->stop();
else
m_autocomplete_timer->start();
}
insert_at_cursor_or_replace_selection(sb.to_string());
return;
}