Pārlūkot izejas kodu

LibGUI: Don't re-trigger the autocomplete box when the timer fires

Previously there was a situation where the autocomplete box would
appear to "jump" to the side. This was due to the following race
condition:

1. Start typing, thus triggering the autocomplete timer to start
2. Manually trigger autocomplete before the timer finishes
3. Continue typing
4. The autocomplete timer now fires

When the timer fires it causes the autocomplete box to show, which, if
it is already shown, has the effect of moving the box to the current
cursor position.
thislooksfun 3 gadi atpakaļ
vecāks
revīzija
7a2c8452f1
1 mainītis faili ar 4 papildinājumiem un 1 dzēšanām
  1. 4 1
      Userland/Libraries/LibGUI/TextEditor.cpp

+ 4 - 1
Userland/Libraries/LibGUI/TextEditor.cpp

@@ -1987,7 +1987,10 @@ void TextEditor::set_should_autocomplete_automatically(bool value)
 
     if (value) {
         VERIFY(m_autocomplete_provider);
-        m_autocomplete_timer = Core::Timer::create_single_shot(m_automatic_autocomplete_delay_ms, [this] { try_show_autocomplete(UserRequestedAutocomplete::No); });
+        m_autocomplete_timer = Core::Timer::create_single_shot(m_automatic_autocomplete_delay_ms, [this] {
+            if (m_autocomplete_box && !m_autocomplete_box->is_visible())
+                try_show_autocomplete(UserRequestedAutocomplete::No);
+        });
         return;
     }