diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index c90d8b418c..025f48d001 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1194,6 +1194,10 @@ static bool gotchars_add_byte(gotchars_state_T *state, uint8_t byte) goto ret_false; } c = TO_SPECIAL(state->prev_c, c); + // Drop K_COMPLETE_DELAY, it's not useful in a recording. + if (c == K_COMPLETE_DELAY) { + state->buflen = 0; + } } // When receiving a multibyte character, store it until we have all // the bytes, so that it won't be split between two buffer blocks, diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 84475d4443..29aa6d0cad 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -150,9 +150,9 @@ int input_get(uint8_t *buf, int maxlen, int ms, int tb_change_cnt, MultiQueue *e // '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/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index d5b60c789d..72e2a11f1a 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -6124,10 +6124,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') || has('nvim') + 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