patch 9.1.1970: visual end column returns wrong value after block edit

Commit: 
https://github.com/vim/vim/commit/fa3bdc2501faeae7f3211fc8559ded43e27b864c
Author: phanium <[email protected]>
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 <[email protected]>
    Signed-off-by: phanium <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vTmb4-00AE9v-6B%40256bit.org.

Raspunde prin e-mail lui