]> git.ipfire.org Git - thirdparty/vim.git/commit
patch 9.2.0739: completion: 'autocompletedelay' blocks the main loop and drops autoco... v9.2.0739
authorHirohito Higashi <h.east.727@gmail.com>
Sun, 28 Jun 2026 16:24:13 +0000 (16:24 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 28 Jun 2026 16:27:06 +0000 (16:27 +0000)
commit8ce43ea4e3cb315f566bcd9048c254ba58042964
tree28ddc798524d08925ef4d164eac6d42cb2ece0e7
parent1f33732613304958c935f302d8cb44bddc7f672f
patch 9.2.0739: completion: 'autocompletedelay' blocks the main loop and drops autocommands

Problem:  With a non-zero 'autocompletedelay', Insert-mode autocommands
          (TextChangedI, TextChangedP, CursorMovedI) are delayed, and
          while typing faster than the delay they are dropped entirely,
          because the delay blocks the main loop.
Solution: Make 'autocompletedelay' non-blocking: instead of busy-waiting
          before showing the popup menu, defer it with an input-wait
          timeout (K_COMPLETE_DELAY) modeled on CursorHoldI, so typing
          stays responsive and the Insert-mode autocommands fire normally.

The delay timer coexists with 'updatetime': the main loop waits for the
sooner of the two and triggers the event whose deadline was reached, so
'autocompletedelay' no longer shadows CursorHold timing.  Changing the
completion leader, for example with Backspace, updates the visible popup
immediately like a zero delay; only the first popup is deferred.

Update the 'autocompletedelay' screendumps for the non-blocking display.
One test opened the menu with CTRL-N right after the delay expired and
could race with the deferred popup, so it now waits a little longer than
the delay before sending the key.

fixes:  #20591
closes: #20598

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
14 files changed:
src/edit.c
src/getchar.c
src/insexpand.c
src/keymap.h
src/proto/insexpand.pro
src/testdir/dumps/Test_autocompletedelay_2.dump
src/testdir/dumps/Test_autocompletedelay_3.dump
src/testdir/dumps/Test_autocompletedelay_5.dump
src/testdir/dumps/Test_autocompletedelay_longest_1.dump
src/testdir/dumps/Test_autocompletedelay_longest_3.dump
src/testdir/dumps/Test_autocompletedelay_preinsert_1.dump
src/testdir/test_ins_complete.vim
src/ui.c
src/version.c