patch 9.2.0755: 'autocomplete' behaves inconsistently when recording
Commit:
https://github.com/vim/vim/commit/a658728918405294e134fbc81f13b50311924db5
Author: zeertzjq <
zeer...@outlook.com>
Date: Tue Jun 30 18:27:55 2026 +0000
patch 9.2.0755: 'autocomplete' behaves inconsistently when recording
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 <
zeer...@outlook.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/getchar.c b/src/getchar.c
index a192d1462..83e4be3eb 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -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
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index 4165002cd..3d4c3fb30 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -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
diff --git a/src/ui.c b/src/ui.c
index ee6837d8d..ea4dc64a2 100644
--- 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;
diff --git a/src/version.c b/src/version.c
index 90ad6a7b5..3ce9aee7e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -759,6 +759,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 755,
/**/
754,
/**/