]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0749: 'autocompletedelay' interferes with i_CTRL-K v9.2.0749
authorzeertzjq <zeertzjq@outlook.com>
Sun, 28 Jun 2026 19:30:58 +0000 (19:30 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 28 Jun 2026 19:30:58 +0000 (19:30 +0000)
Problem:  'autocompletedelay' interferes with i_CTRL-K (after 9.2.0739).
Solution: Clear the pending autocompltion from the previous key when a
          new key is typed.

closes: #20666

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

index 93910de6b5fea1c146174429a7c449f9ee9063b9..bc8ce4128d257f62179b5b952dae1046c4e4d7b6 100644 (file)
@@ -677,6 +677,9 @@ edit(
 
        // Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V.
        did_cursorhold = TRUE;
+       if (c != K_CURSORHOLD && c != K_COMPLETE_DELAY)
+           // Don't want delayed autocompletion from the previous key either.
+           ins_compl_clear_autocomplete_delay();
 
 #ifdef FEAT_RIGHTLEFT
        if (p_hkmap && KeyTyped)
index b178ad272beda284015507d0255dda6ce9431161..cdcdb217e39524a5b0457f8cfc0ee49cb73f8fd7 100644 (file)
@@ -6000,6 +6000,27 @@ func Test_autocompletedelay_ctrl_g_U()
   call Run_test_autocompletedelay_ctrl_g_U(150, 500)
 endfunc
 
+func Run_test_autocompletedelay_ctrl_k(delay1, delay2)
+  new
+  call setline(1, 'foo bar baz')
+  set autocomplete autocompletedelay=200
+
+  call timer_start(a:delay1, { -> feedkeys("\<C-K>", 't') })
+  call timer_start(a:delay2, { -> feedkeys(".,\<Esc>", 't') })
+  call feedkeys('ob', 'tx!')
+  call assert_equal(['foo bar baz', 'b…'], getline(1, '$'))
+
+  set autocomplete& autocompletedelay&
+  bwipe!
+endfunc
+
+func Test_autocompletedelay_ctrl_k()
+  " Ctrl-K typed after 'autocompletedelay' expires
+  call Run_test_autocompletedelay_ctrl_k(250, 500)
+  " Ctrl-K typed before 'autocompletedelay' expires
+  call Run_test_autocompletedelay_ctrl_k(150, 500)
+endfunc
+
 " Preinsert longest prefix when autocomplete
 func Test_autocomplete_longest()
   func GetLine()
index 784016772a70aa2ab9a1972998b6cdf82fcbe4a8..a42f2bd83935e2e56ddd23196ad6a36b9e24a5e2 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    749,
 /**/
     748,
 /**/