]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0748: 'autocompletedelay' interferes with CTRL-G U v9.2.0748
authorzeertzjq <zeertzjq@outlook.com>
Sun, 28 Jun 2026 19:27:31 +0000 (19:27 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 28 Jun 2026 19:27:31 +0000 (19:27 +0000)
Problem:  'autocompletedelay' interferes with CTRL-G U (after 9.2.0739).
Solution: Restore the flag for CTRL-G U.

related: #8937
related: #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 1860ba3716c6de83dea3f55319fb44e079c08512..93910de6b5fea1c146174429a7c449f9ee9063b9 100644 (file)
@@ -1171,6 +1171,9 @@ doESCkey:
            break;
 
        case K_COMPLETE_DELAY:  // 'autocompletedelay' expired
+           // If CTRL-G U was used apply it to the next typed key.
+           if (dont_sync_undo == TRUE)
+               dont_sync_undo = MAYBE;
            ins_compl_clear_autocomplete_delay();
            if (!ins_compl_has_autocomplete() || char_avail()
                    || curwin->w_cursor.col == 0)
index 00fcf4e44d706e8f9fceaba98f3ad2f9ddec8195..b178ad272beda284015507d0255dda6ce9431161 100644 (file)
@@ -5976,6 +5976,30 @@ func Test_autocompletedelay()
   call StopVimInTerminal(buf)
 endfunc
 
+func Run_test_autocompletedelay_ctrl_g_U(delay1, delay2)
+  new
+  call setline(1, 'foo bar baz')
+  inoremap <buffer> ( ()<C-g>U
+  set autocomplete autocompletedelay=200
+
+  call timer_start(a:delay1, { -> feedkeys('(', 't') })
+  call timer_start(a:delay2, { -> feedkeys("\<Left>a\<Esc>", 't') })
+  call feedkeys('ob', 'tx!')
+  call assert_equal(['foo bar baz', 'b(a)'], getline(1, '$'))
+  undo
+  call assert_equal(['foo bar baz'], getline(1, '$'))
+
+  set autocomplete& autocompletedelay&
+  bwipe!
+endfunc
+
+func Test_autocompletedelay_ctrl_g_U()
+  " '(' typed after 'autocompletedelay' expires
+  call Run_test_autocompletedelay_ctrl_g_U(250, 500)
+  " '(' typed before 'autocompletedelay' expires
+  call Run_test_autocompletedelay_ctrl_g_U(150, 500)
+endfunc
+
 " Preinsert longest prefix when autocomplete
 func Test_autocomplete_longest()
   func GetLine()
index 696a78c404de1207e57e37f63cff72ccc456acbb..784016772a70aa2ab9a1972998b6cdf82fcbe4a8 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    748,
 /**/
     747,
 /**/