vim-patch:9.1.1464: gv does not work in operator-pending mode (#34534)

Problem:  gv does not work in operator-pending mode
          (liushapku)
Solution: remove the check for checkclearop in nv_gv_cmd()
          (phanium)

fixes: vim/vim#3666
closes: vim/vim#17551

cb27992cda

Co-authored-by: phanium <91544758+phanen@users.noreply.github.com>
This commit is contained in:
zeertzjq
2025-06-17 08:27:41 +08:00
committed by GitHub
parent 3e984cf02b
commit ae0981070e
3 changed files with 9 additions and 6 deletions

View File

@ -251,6 +251,7 @@ CHANGED FEATURES *news-changed*
These existing features changed their behavior.
• |gv| works in operator pending mode and does not abort.
• 'smartcase' applies to completion filtering.
• 'spellfile' location defaults to `stdpath("data").."/site/spell/"` instead of
the first writable directory in 'runtimepath'.

View File

@ -5157,10 +5157,6 @@ static void nv_suspend(cmdarg_T *cap)
/// exchange previous and current Visual area.
static void nv_gv_cmd(cmdarg_T *cap)
{
if (checkclearop(cap->oap)) {
return;
}
if (curbuf->b_visual.vi_start.lnum == 0
|| curbuf->b_visual.vi_start.lnum > curbuf->b_ml.ml_line_count
|| curbuf->b_visual.vi_end.lnum == 0) {

View File

@ -2611,8 +2611,14 @@ func Test_normal33_g_cmd2()
exe "norm! G0\<c-v>4k4ly"
exe "norm! gvood"
call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'fgh', 'fgh', 'fgh', 'fgh', 'fgh'], getline(1,'$'))
" gv cannot be used in operator pending mode
call assert_beeps('normal! cgv')
" gv works in operator pending mode
call assert_nobeep('normal! cgvxyza')
call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'xyza', 'xyza', 'xyza', 'xyza', 'xyza'], getline(1,'$'))
exe "norm! ^\<c-v>Gydgv..cgvbc"
call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'bc', 'bc', 'bc', 'bc', 'bc'], getline(1,'$'))
exe "norm! v^GragggUgv"
call assert_equal(['', 'abfgh', 'abfgh', 'abfgh', 'bA', 'AA', 'AA', 'AA', 'Ac'], getline(1,'$'))
" gv should beep without a previously selected visual area
new
call assert_beeps('normal! gv')