]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1354: "gr CTRL-G" stays in virtual replace mode v9.0.1354
authorBram Moolenaar <Bram@vim.org>
Sat, 25 Feb 2023 14:24:44 +0000 (14:24 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 25 Feb 2023 14:24:44 +0000 (14:24 +0000)
Problem:    "gr CTRL-G" stays in virtual replace mode. (Pierre Ganty)
Solution:   Prepend CTRL-V before control characters. (closes #12045)

src/edit.c
src/normal.c
src/testdir/test_edit.vim
src/version.c

index a030e537a6a47333c28dc4089941cfe058986d2a..ff9fc0ed0fb93490a15ee1de1cfb3eaff742f66c 100644 (file)
@@ -3527,6 +3527,10 @@ ins_ctrl_g(void)
                  dont_sync_undo = MAYBE;
                  break;
 
+       case ESC:
+                 // Esc after CTRL-G cancels it.
+                 break;
+
        // Unknown CTRL-G command, reserved for future expansion.
        default:  vim_beep(BO_CTRLG);
     }
index b3ea5e8bca5473a0d62dabdfb5245679d295eea5..95bb1a97d68f650349a710374b350711c04d8e23 100644 (file)
@@ -5033,6 +5033,10 @@ nv_vreplace(cmdarg_T *cap)
     {
        if (cap->extra_char == Ctrl_V)  // get another character
            cap->extra_char = get_literal(FALSE);
+       if (cap->extra_char < ' ')
+           // Prefix a control character with CTRL-V to avoid it being used as
+           // a command.
+           stuffcharReadbuff(Ctrl_V);
        stuffcharReadbuff(cap->extra_char);
        stuffcharReadbuff(ESC);
        if (virtual_active())
index 1b00ae98f99f0761a7f11b98a6fd68fa6e00d09e..f0896d2c5cbb3d1c4359cf5a7eb6fcd60a47c3a6 100644 (file)
@@ -2068,8 +2068,12 @@ endfunc
 func Test_edit_gr_special()
   enew
   call setline(1, ['abcdef', 'xxxxxx'])
-  exe "normal! gr\<C-O>x"
-  call assert_equal('bcdef', getline(1))
+  exe "normal! gr\<C-O>lx"
+  call assert_equal("\<C-O>def", getline(1))
+
+  call setline(1, 'abcdef')
+  exe "normal! 0gr\<C-G>lx"
+  call assert_equal("\<C-G>def", getline(1))
 
   bwipe!
 endfunc
index c3631e6ccd28d716b744daebc247e9cc3c5458e1..315f91eac2b0d2824bd83a1240250e0e7b888743 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1354,
 /**/
     1353,
 /**/