]> granicus.if.org Git - vim/commitdiff
patch 8.0.0341: undo does not work properly when using completion v8.0.0341
authorBram Moolenaar <Bram@vim.org>
Sun, 19 Feb 2017 14:26:18 +0000 (15:26 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 19 Feb 2017 14:26:18 +0000 (15:26 +0100)
Problem:    When using complete() and typing a character undo is saved after
            the character was inserted. (Shougo)
Solution:   Save for undo before inserting the character.

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

index a37261ffab333336519434962204f7610f6477d5..d7f89bcbed8b36245345a8804206f663b698a08d 100644 (file)
@@ -3583,7 +3583,11 @@ ins_compl_addleader(int c)
 {
 #ifdef FEAT_MBYTE
     int                cc;
+#endif
 
+    if (stop_arrow() == FAIL)
+       return;
+#ifdef FEAT_MBYTE
     if (has_mbyte && (cc = (*mb_char2len)(c)) > 1)
     {
        char_u  buf[MB_MAXBYTES + 1];
index f4ce064d7ba5bba0e861d3d6b2abc3650df35f43..2c6afa06c286ad43f60fd440f6430a5f8ff9a35b 100644 (file)
@@ -531,4 +531,24 @@ func Test_completion_respect_bs_option()
   bw!
 endfunc
 
+func CompleteUndo() abort
+  call complete(1, g:months)
+  return ''
+endfunc
+
+func Test_completion_can_undo()
+  inoremap <Right> <c-r>=CompleteUndo()<cr>
+  set completeopt+=noinsert,noselect
+
+  new
+  call feedkeys("a\<Right>a\<Esc>", 'xt')
+  call assert_equal('a', getline(1))
+  undo
+  call assert_equal('', getline(1))
+
+  bwipe!
+  set completeopt&
+  iunmap <Right>
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index ef71d0e3919d8a1bd8b843a230e0523663a25621..f12c508d49f6d1c0134a1ee3a57efe1b06a99eb6 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    341,
 /**/
     340,
 /**/