patch 9.1.1970: visual end column returns wrong value after block edit
Commit:
https://github.com/vim/vim/commit/fa3bdc2501faeae7f3211fc8559ded43e27b864c
Author: phanium <
9154475...@users.noreply.github.com>
Date: Thu Dec 11 20:39:27 2025 +0100
patch 9.1.1970: visual end column returns wrong value after block edit
Problem: visual end column returns wrong value after block edit
Solution: update visual end column after block insert (phanium)
fixes: #18900
closes: #18903
Co-authored-by: zeertzjq <
zeer...@outlook.com>
Signed-off-by: phanium <
9154475...@users.noreply.github.com>
Signed-off-by: Christian Brabandt <
c...@256bit.org>
diff --git a/src/ops.c b/src/ops.c
index 1544f34d4..7e1bb1bfb 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -754,6 +754,11 @@ block_insert(
// the insert in the first line.
curbuf->b_op_end.lnum = oap->end.lnum;
curbuf->b_op_end.col = offset;
+ if (curbuf->b_visual.vi_end.coladd)
+ {
+ curbuf->b_visual.vi_end.col += curbuf->b_visual.vi_end.coladd;
+ curbuf->b_visual.vi_end.coladd = 0;
+ }
}
} // for all lnum
diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim
index 4fab92546..557271a06 100644
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -2822,4 +2822,17 @@ func Test_visual_pos_buffer_heap_overflow()
bw! Xa Xb
endfunc
+" Test visual block pos update after block insert and gv
+func Test_visual_block_pos_update()
+ new
+ set virtualedit=block
+ call setline(1, ['aacccc', 'bb'])
+ exe "norm! e\<C-v>jAa\<Esc>gv"
+ call assert_equal([[0, 1, 6, 0], [0 , 2, 6, 0]], [getpos("v"), getpos(".")])
+ normal! kj
+ call assert_equal([[0, 1, 6, 0], [0 , 2, 6, 0]], [getpos("v"), getpos(".")])
+ set virtualedit=
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 6b6dde51e..2e806c33c 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 */
+/**/
+ 1970,
/**/
1969,
/**/