From: zeertzjq Date: Tue, 30 Jun 2026 18:27:55 +0000 (+0000) Subject: patch 9.2.0755: 'autocomplete' behaves inconsistently when recording X-Git-Tag: v9.2.0755^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a658728918405294e134fbc81f13b50311924db5;p=thirdparty%2Fvim.git 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 Signed-off-by: Christian Brabandt --- diff --git a/src/getchar.c b/src/getchar.c index a192d14628..83e4be3ebb 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 4165002cd8..3d4c3fb305 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("\q", 't') }) + call timer_start(300, { -> feedkeys("\q", 't') }) call feedkeys("qaSf", 'tx!') call assert_equal("Sf\", @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("\\\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\\\", @a) + endif + set autocomplete& autocompletedelay& bwipe! endfunc diff --git a/src/ui.c b/src/ui.c index ee6837d8d6..ea4dc64a2a 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 90ad6a7b5f..3ce9aee7ed 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, /**/