]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1970: visual end column returns wrong value after block edit v9.1.1970
authorphanium <91544758+phanen@users.noreply.github.com>
Thu, 11 Dec 2025 19:39:27 +0000 (20:39 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 11 Dec 2025 19:39:27 +0000 (20:39 +0100)
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 <zeertzjq@outlook.com>
Signed-off-by: phanium <91544758+phanen@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ops.c
src/testdir/test_visual.vim
src/version.c

index 1544f34d47abb615b9da9f7b1e177b7a69011b99..7e1bb1bfb494697ebd73d36d27ca8526efd45131 100644 (file)
--- 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
 
index 4fab9254637d818e0be6473118ee400716970680..557271a06cb04483d8f535afa12e1572c6d0cc9d 100644 (file)
@@ -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
index 6b6dde51ebeae65277203edebabe993a9584f904..2e806c33c16f9e4d5dbbb5627369b4228fef5bea 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1970,
 /**/
     1969,
 /**/