]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1521: failing redo of command with control characters v9.0.1521
authorzeertzjq <zeertzjq@outlook.com>
Sun, 7 May 2023 16:39:23 +0000 (17:39 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 7 May 2023 16:39:23 +0000 (17:39 +0100)
Problem:    Failing redo of command with control characters.
Solution:   Use AppendToRedobuffLit() for colon commands. (closes #12354)

src/getchar.c
src/ops.c
src/testdir/test_normal.vim
src/version.c

index d510e45d91c551b50e7b06dfdefcd59d1149af91..1c3cdb19dc41b3d087d3584d741991cb82d067af 100644 (file)
@@ -43,8 +43,8 @@ static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0};
 static int typeahead_char = 0;         // typeahead char that's not flushed
 
 /*
- * when block_redo is TRUE redo buffer will not be changed
- * used by edit() to repeat insertions and 'V' command for redoing
+ * When block_redo is TRUE the redo buffer will not be changed.
+ * Used by edit() to repeat insertions.
  */
 static int     block_redo = FALSE;
 
@@ -609,11 +609,14 @@ AppendToRedobuffLit(
     void
 AppendToRedobuffSpec(char_u *s)
 {
+    if (block_redo)
+       return;
+
     while (*s != NUL)
     {
        if (*s == K_SPECIAL && s[1] != NUL && s[2] != NUL)
        {
-           // insert special key literally
+           // Insert special key literally.
            add_buff(&redobuff, s, 3L);
            s += 3;
        }
index 4c64e05b2cbacecd4800cc452ad433f484b8bbaf..d46a049fe4e790715fb79f1164f8f650bd368e25 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -3701,7 +3701,10 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
                    ResetRedobuff();
                else
                {
-                   AppendToRedobuffSpec(repeat_cmdline);
+                   if (cap->cmdchar == ':')
+                       AppendToRedobuffLit(repeat_cmdline, -1);
+                   else
+                       AppendToRedobuffSpec(repeat_cmdline);
                    AppendToRedobuff(NL_STR);
                    VIM_CLEAR(repeat_cmdline);
                }
index 03d29ae97bec335c75198d1a9bf2b8815f993944..470b41cb08dc7407ec723f89500d72a5cac527e3 100644 (file)
@@ -3635,11 +3635,32 @@ func Test_horiz_motion()
   bwipe!
 endfunc
 
-" Test for using a : command in operator pending mode
+" Test for using a ":" command in operator pending mode
 func Test_normal_colon_op()
   new
   call setline(1, ['one', 'two'])
   call assert_beeps("normal! Gc:d\<CR>")
+  call assert_equal(['one'], getline(1, '$'))
+
+  call setline(1, ['one…two…three!'])
+  normal! $
+  " Using ":" as a movement is characterwise exclusive
+  call feedkeys("d:normal! F…\<CR>", 'xt')
+  call assert_equal(['one…two!'], getline(1, '$'))
+  " Check that redoing a command with 0x80 bytes works
+  call feedkeys('.', 'xt')
+  call assert_equal(['one!'], getline(1, '$'))
+
+  call setline(1, ['one', 'two', 'three', 'four', 'five'])
+  " Add this to the command history
+  call feedkeys(":normal! G0\<CR>", 'xt')
+  " Use :normal! with control characters in operator pending mode
+  call feedkeys("d:normal! \<C-V>\<C-P>\<C-V>\<C-P>\<CR>", 'xt')
+  call assert_equal(['one', 'two', 'five'], getline(1, '$'))
+  " Check that redoing a command with control characters works
+  call feedkeys('.', 'xt')
+  call assert_equal(['five'], getline(1, '$'))
+
   bwipe!
 endfunc
 
index 35ea18aea5e5d8f5ff47445f05d37d14911609fe..454e246d40f6a6ffe8bac2bbf5ada6c669047adf 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1521,
 /**/
     1520,
 /**/