]> granicus.if.org Git - vim/commitdiff
patch 8.2.3467: CursorHoldI event interferes with "CTRL-G U" v8.2.3467
authorBram Moolenaar <Bram@vim.org>
Sun, 3 Oct 2021 15:22:05 +0000 (16:22 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 3 Oct 2021 15:22:05 +0000 (16:22 +0100)
Problem:    CursorHoldI event interferes with "CTRL-G U". (Naohiro Ono)
Solution:   Restore the flag for "CTRL-G U" after triggering CursorHoldI.
            (closes #8937)

src/edit.c
src/testdir/test_autocmd.vim
src/version.c

index 070d84c609ef8467ab4731060a71b2500af9b5f3..4f8e3740177688414575602abb2aaeceab08efa9 100644 (file)
@@ -1057,6 +1057,9 @@ doESCkey:
        case K_CURSORHOLD:      // Didn't type something for a while.
            ins_apply_autocmds(EVENT_CURSORHOLDI);
            did_cursorhold = TRUE;
+           // If CTRL-G U was used apply it to the next typed key.
+           if (dont_sync_undo == TRUE)
+               dont_sync_undo = MAYBE;
            break;
 
 #ifdef FEAT_GUI_MSWIN
index f769eec17fe2f01424fe2103cc81ad9b655df873..db1efba12db6f369d75e557d954da73747003ed7 100644 (file)
@@ -100,6 +100,22 @@ if has('timers')
     set updatetime&
   endfunc
 
+  func Test_cursorhold_insert_ctrl_g_U()
+    au CursorHoldI * :
+    set updatetime=20
+    new
+    call timer_start(100, { -> feedkeys("\<Left>foo\<Esc>", 't') })
+    call feedkeys("i()\<C-g>U", 'tx!')
+    sleep 200m
+    call assert_equal('(foo)', getline(1))
+    undo
+    call assert_equal('', getline(1))
+
+    bwipe!
+    au! CursorHoldI
+    set updatetime&
+  endfunc
+
   func Test_OptionSet_modeline()
     call test_override('starting', 1)
     au! OptionSet
index 080170408571e562704aec3c4627cc92c1650fb3..410776742ffc41c8187b12fea3b37929721086a0 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3467,
 /**/
     3466,
 /**/