From ae0981070e25a7ac8d7566f7218c11d8b2a548f0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 17 Jun 2025 08:27:41 +0800 Subject: [PATCH] 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 https://github.com/vim/vim/commit/cb27992cdadd3a17a9094096f0972fa806f0240d Co-authored-by: phanium <91544758+phanen@users.noreply.github.com> --- runtime/doc/news.txt | 1 + src/nvim/normal.c | 4 ---- test/old/testdir/test_normal.vim | 10 ++++++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index 3f97fa3baa..9de08bef81 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -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'. diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 45c1ea474d..ba30b5ddff 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -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) { diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim index 465ed2bbed..89e9304226 100644 --- a/test/old/testdir/test_normal.vim +++ b/test/old/testdir/test_normal.vim @@ -2611,8 +2611,14 @@ func Test_normal33_g_cmd2() exe "norm! G0\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! ^\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')