From adc85151f3c6a6cea4bb8c8da3465429fc120445 Mon Sep 17 00:00:00 2001 From: varsidry <240319857+varsidry@users.noreply.github.com> Date: Fri, 31 Oct 2025 16:16:11 +0000 Subject: [PATCH] patch 9.1.1891: g does not move to last non-blank in visual mode Problem: In visual mode, g does not move to the last non-blank character when the end of a line is on the same line as the cursor (after v9.0.1753) Solution: Move the cursor back by one position if it lands after the line (varsidry) fixes: #18657 closes: #18658 Signed-off-by: varsidry <240319857+varsidry@users.noreply.github.com> Signed-off-by: Christian Brabandt --- runtime/doc/index.txt | 5 +++-- src/normal.c | 2 +- src/testdir/test_normal.vim | 11 +++++++++++ src/version.c | 2 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt index 2966a6303f..0581a83699 100644 --- a/runtime/doc/index.txt +++ b/runtime/doc/index.txt @@ -1,4 +1,4 @@ -*index.txt* For Vim version 9.1. Last change: 2025 Aug 06 +*index.txt* For Vim version 9.1. Last change: 2025 Oct 31 VIM REFERENCE MANUAL by Bram Moolenaar @@ -807,7 +807,8 @@ tag char note action in Normal mode ~ |g@| g@{motion} call 'operatorfunc' |g~| g~{motion} 2 swap case for Nmove text |g| g 1 same as "gj" -|g| g 1 same as "g$" +|g| g 1 same as "g$" but go to the rightmost + non-blank character instead |g| g 1 same as "g0" |g| g same as g same as diff --git a/src/normal.c b/src/normal.c index 63edaa964c..0f336a276d 100644 --- a/src/normal.c +++ b/src/normal.c @@ -5936,7 +5936,7 @@ nv_g_dollar_cmd(cmdarg_T *cap) { do i = gchar_cursor(); - while (VIM_ISWHITE(i) && oneleft() == OK); + while (IS_WHITE_OR_NUL(i) && oneleft() == OK); curwin->w_valid &= ~VALID_WCOL; } } diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index 374696443d..58c1b97832 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -4195,6 +4195,17 @@ func Test_normal33_g_cmd_nonblank() call assert_equal(20, col('.')) exe "normal 0g\" call assert_equal(11, col('.')) + + " Test visual mode at end of line + normal 0$bvg$y + call assert_equal(80, col("'>")) + exe "normal 0$bvg\y" + call assert_equal(71, col("'>")) + setlocal nowrap virtualedit=all + exe "normal 0$\llg\y" + call assert_equal(71, col("'<")) + exe "normal 0$llvg\y" + call assert_equal(71, col("'<")) bw! endfunc diff --git a/src/version.c b/src/version.c index 5af88e6115..df3adb3bb2 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1891, /**/ 1890, /**/ -- 2.47.3