commit ae0981070e25a7ac8d7566f7218c11d8b2a548f0
parent 3e984cf02bdcebe2d4f31792505b6a3784fd1b1b
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue, 17 Jun 2025 08:27:41 +0800
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>
Diffstat:
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git 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
@@ -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
@@ -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')