]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0755: 'autocomplete' behaves inconsistently when recording v9.2.0755
authorzeertzjq <zeertzjq@outlook.com>
Tue, 30 Jun 2026 18:27:55 +0000 (18:27 +0000)
committerChristian Brabandt <cb@256bit.org>
Tue, 30 Jun 2026 18:27:55 +0000 (18:27 +0000)
Problem:  If 'autocompletedelay' is non-zero, 'autocomplete' doesn't
          work when recording a register (after 9.2.0750).
Solution: Still produce K_COMPLETE_DELAY when recording a register, and
          drop it in gotchars_add_byte() instead (zeertzjq).

This patch only changes the behavior when recording a register.
Replaying a register with 'autocomplete' still doesn't fully work
regardless of 'autocompletedelay', as 'autocomplete' isn't triggered
when there is pending input.

closes: #20675

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/getchar.c
src/testdir/test_ins_complete.vim
src/ui.c
src/version.c

index a192d146286b547822a3b988eb46e36e44b20773..83e4be3ebb27c0d1c179b9ccce434e8e71d85e2a 100644 (file)
@@ -1379,9 +1379,9 @@ gotchars_add_byte(gotchars_state_T *state, char_u byte)
                // When receiving a modifier, wait for the modified key.
                goto ret_false;
            c = TO_SPECIAL(state->prev_c, c);
-           if (c == K_FOCUSGAINED || c == K_FOCUSLOST)
-               // Drop K_FOCUSGAINED and K_FOCUSLOST, they are not useful
-               // in a recording.
+           // Drop K_FOCUSGAINED, K_FOCUSLOST and K_COMPLETE_DELAY, they are
+           // not useful in a recording.
+           if (c == K_FOCUSGAINED || c == K_FOCUSLOST || c == K_COMPLETE_DELAY)
                state->buflen = 0;
        }
        // When receiving a multibyte character, store it until we have all
index 4165002cd8a77f26134b5cb6d31f2f5f4455e572..3d4c3fb305c488e6b686317e9fd7e1d03d9d391e 100644 (file)
@@ -6031,10 +6031,20 @@ func Test_autocompletedelay_no_record()
   let @a = ''
   " Type a char that arms the delay, idle past 'autocompletedelay' so a
   " K_COMPLETE_DELAY would be injected, then end Insert mode and stop recording.
-  call timer_start(200, { -> feedkeys("\<Esc>q", 't') })
+  call timer_start(300, { -> feedkeys("\<Esc>q", 't') })
   call feedkeys("qaSf", 'tx!')
   call assert_equal("Sf\<Esc>", @a)
 
+  " Delayed autocompletion still works when recording.
+  if !has('win32') " FIXME: does not work on Windows
+    call setline(1, 'foobar foofoo')
+    call timer_start(300, { -> feedkeys("\<Down>\<C-Y>\<Esc>q", 't') })
+    call feedkeys("qaof", 'tx!')
+    call assert_equal('foobar', getline('.'))
+    " XXX: This doesn't produce the same result when replaying.
+    call assert_equal("of\<Down>\<C-Y>\<Esc>", @a)
+  endif
+
   set autocomplete& autocompletedelay&
   bwipe!
 endfunc
index ee6837d8d6a2353fe3a58179f756e57e0dac3f3b..ea4dc64a2ad34f8444b7d72fc9e66b78ebe7e2c8 100644 (file)
--- a/src/ui.c
+++ b/src/ui.c
@@ -305,9 +305,9 @@ inchar_loop(
        // 'autocompletedelay' and 'updatetime' so the delay does not postpone
        // CursorHold.  Once CursorHold has fired, only the delay is left.
        // Gate the injection like trigger_cursorhold() so the deferred key
-       // cannot fire while recording or outside Insert mode.
+       // cannot fire while outside Insert mode, but do still fire the key
+       // when recording a register (gotchars_add_byte() will ignore it).
        bool delay_pending = ins_compl_autocomplete_pending() && p_acl > 0
-               && reg_recording == 0
                && typebuf.tb_len == 0
                && !ins_compl_active()
                && (get_real_state() & MODE_INSERT) != 0;
index 90ad6a7b5f9c46d8e2bf3d3c5ee2b1ad6cac3073..3ce9aee7ede6d33ff183f9ceef81a3a5180eebe9 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    755,
 /**/
     754,
 /**/