mirror of
https://github.com/neovim/neovim.git
synced 2025-11-05 10:14:26 +00:00
Merge pull request #22411 from zeertzjq/vim-9.0.1354
vim-patch:9.0.{1354,1356}: "gr CTRL-G" stays in virtual replace mode
This commit is contained in:
@@ -3444,6 +3444,10 @@ static void ins_ctrl_g(void)
|
|||||||
dont_sync_undo = kNone;
|
dont_sync_undo = kNone;
|
||||||
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:
|
default:
|
||||||
vim_beep(BO_CTRLG);
|
vim_beep(BO_CTRLG);
|
||||||
|
|||||||
@@ -4710,7 +4710,7 @@ static void nv_vreplace(cmdarg_T *cap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkclearopq(cap->oap)) {
|
if (checkclearopq(cap->oap) || cap->extra_char == ESC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4720,6 +4720,11 @@ static void 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()) {
|
||||||
|
|||||||
@@ -580,6 +580,7 @@ func Test_edit_CTRL_G()
|
|||||||
call assert_equal([0, 3, 7, 0], getpos('.'))
|
call assert_equal([0, 3, 7, 0], getpos('.'))
|
||||||
call feedkeys("i\<c-g>j\<esc>", 'tnix')
|
call feedkeys("i\<c-g>j\<esc>", 'tnix')
|
||||||
call assert_equal([0, 3, 6, 0], getpos('.'))
|
call assert_equal([0, 3, 6, 0], getpos('.'))
|
||||||
|
call assert_nobeep("normal! i\<c-g>\<esc>")
|
||||||
bw!
|
bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
|||||||
@@ -3283,9 +3283,9 @@ func Test_delete_until_paragraph()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Test for the gr (virtual replace) command
|
" Test for the gr (virtual replace) command
|
||||||
" Test for the bug fixed by 7.4.387
|
|
||||||
func Test_gr_command()
|
func Test_gr_command()
|
||||||
enew!
|
enew!
|
||||||
|
" Test for the bug fixed by 7.4.387
|
||||||
let save_cpo = &cpo
|
let save_cpo = &cpo
|
||||||
call append(0, ['First line', 'Second line', 'Third line'])
|
call append(0, ['First line', 'Second line', 'Third line'])
|
||||||
exe "normal i\<C-G>u"
|
exe "normal i\<C-G>u"
|
||||||
@@ -3298,10 +3298,12 @@ func Test_gr_command()
|
|||||||
normal 4gro
|
normal 4gro
|
||||||
call assert_equal('ooooecond line', getline(2))
|
call assert_equal('ooooecond line', getline(2))
|
||||||
let &cpo = save_cpo
|
let &cpo = save_cpo
|
||||||
|
|
||||||
normal! ggvegrx
|
normal! ggvegrx
|
||||||
call assert_equal('xxxxx line', getline(1))
|
call assert_equal('xxxxx line', getline(1))
|
||||||
exe "normal! gggr\<C-V>122"
|
exe "normal! gggr\<C-V>122"
|
||||||
call assert_equal('zxxxx line', getline(1))
|
call assert_equal('zxxxx line', getline(1))
|
||||||
|
|
||||||
set virtualedit=all
|
set virtualedit=all
|
||||||
normal! 15|grl
|
normal! 15|grl
|
||||||
call assert_equal('zxxxx line l', getline(1))
|
call assert_equal('zxxxx line l', getline(1))
|
||||||
@@ -3309,8 +3311,25 @@ func Test_gr_command()
|
|||||||
set nomodifiable
|
set nomodifiable
|
||||||
call assert_fails('normal! grx', 'E21:')
|
call assert_fails('normal! grx', 'E21:')
|
||||||
call assert_fails('normal! gRx', 'E21:')
|
call assert_fails('normal! gRx', 'E21:')
|
||||||
|
call assert_nobeep("normal! gr\<Esc>")
|
||||||
set modifiable&
|
set modifiable&
|
||||||
enew!
|
|
||||||
|
call assert_nobeep("normal! gr\<Esc>")
|
||||||
|
call assert_beeps("normal! cgr\<Esc>")
|
||||||
|
|
||||||
|
call assert_equal('zxxxx line l', getline(1))
|
||||||
|
exe "normal! 2|gr\<C-V>\<Esc>"
|
||||||
|
call assert_equal("z\<Esc>xx line l", getline(1))
|
||||||
|
|
||||||
|
call setline(1, 'abcdef')
|
||||||
|
exe "normal! 0gr\<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
|
endfunc
|
||||||
|
|
||||||
func Test_nv_hat_count()
|
func Test_nv_hat_count()
|
||||||
|
|||||||
Reference in New Issue
Block a user