0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 9.0.1354: "gr CTRL-G" stays in virtual replace mode

Problem:    "gr CTRL-G" stays in virtual replace mode. (Pierre Ganty)
Solution:   Prepend CTRL-V before control characters. (closes #12045)
This commit is contained in:
Bram Moolenaar
2023-02-25 14:24:44 +00:00
parent 6d611de58c
commit d6a4ea3aa0
4 changed files with 16 additions and 2 deletions

View File

@@ -3527,6 +3527,10 @@ ins_ctrl_g(void)
dont_sync_undo = MAYBE; dont_sync_undo = MAYBE;
break; break;
case ESC:
// Esc after CTRL-G cancels it.
break;
// Unknown CTRL-G command, reserved for future expansion. // Unknown CTRL-G command, reserved for future expansion.
default: vim_beep(BO_CTRLG); default: vim_beep(BO_CTRLG);
} }

View File

@@ -5033,6 +5033,10 @@ nv_vreplace(cmdarg_T *cap)
{ {
if (cap->extra_char == Ctrl_V) // get another character if (cap->extra_char == Ctrl_V) // get another character
cap->extra_char = get_literal(FALSE); 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(cap->extra_char);
stuffcharReadbuff(ESC); stuffcharReadbuff(ESC);
if (virtual_active()) if (virtual_active())

View File

@@ -2068,8 +2068,12 @@ endfunc
func Test_edit_gr_special() func Test_edit_gr_special()
enew enew
call setline(1, ['abcdef', 'xxxxxx']) call setline(1, ['abcdef', 'xxxxxx'])
exe "normal! gr\<C-O>x" exe "normal! gr\<C-O>lx"
call assert_equal('bcdef', getline(1)) 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! bwipe!
endfunc endfunc

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1354,
/**/ /**/
1353, 1353,
/**/ /**/