patch 9.1.0938: exclusive selection not respected when re-selecting block mode

Commit: 
https://github.com/vim/vim/commit/bb955894734b287abfadd3a25786a42038d18d61
Author: Christian Brabandt <c...@256bit.org>
Date:   Mon Dec 16 22:49:15 2024 +0100

    patch 9.1.0938: exclusive selection not respected when re-selecting block 
mode
    
    Problem:  exclusive selection not respected when re-selecting block mode
              (Matt Ellis)
    Solution: advance selection by another character when using
              selection=exclusive and visual block mode
    
    fixes: #16202
    closes: #16219
    
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/normal.c b/src/normal.c
index 87e2cd475..6cf2b9d2f 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -5518,6 +5518,8 @@ nv_visual(cmdarg_T *cap)
                update_curswant_force();
                curwin->w_curswant += resel_VIsual_vcol * cap->count0 - 1;
                curwin->w_cursor.lnum = lnum;
+               if (*p_sel == 'e')
+                   ++curwin->w_curswant;
                coladvance(curwin->w_curswant);
            }
            else
diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim
index 3750ebf6b..0be73ecc1 100644
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -2714,4 +2714,50 @@ func Test_visual_block_cursor_insert_enter()
   bwipe!
 endfunc
 
+func Test_visual_block_exclusive_selection()
+  new
+  set selection=exclusive
+  call setline(1, ['asöd asdf', 'asdf asdf', 'as€d asdf', 'asdf asdf'])
+  call cursor(1, 1)
+  exe ":norm! \<c-v>eh3j~"
+  call assert_equal(['ASÖd asdf', 'ASDf asdf', 'AS€d asdf', 'ASDf asdf'], 
getline(1, '$'))
+  exe ":norm! 1v~"
+  call assert_equal(['asöd asdf', 'asdf asdf', 'as€d asdf', 'asdf asdf'], 
getline(1, '$'))
+  bwipe!
+  set selection&vim
+endfunc
+
+func Test_visual_block_exclusive_selection_adjusted()
+  new
+  " Test that the end-position of the visual selection is adjusted for 
exclusive selection
+  set selection=exclusive
+  call setline(1, ['asöd asdf  ', 'asdf asdf  ', 'as€d asdf  ', 'asdf asdf  '])
+  call cursor(1, 1)
+  " inclusive motion
+  exe ":norm! \<c-v>e3jy"
+  call assert_equal([0, 4, 5, 0], getpos("'>"))
+  " exclusive motion
+  exe ":norm! \<c-v>ta3jy"
+  call assert_equal([0, 4, 6, 0], getpos("'>"))
+  " another inclusive motion
+  exe ":norm! \<c-v>g_3jy"
+  call assert_equal([0, 4, 10, 0], getpos("'>"))
+
+  " Reset selection option to Vim default
+  set selection&vim
+  call cursor(1, 1)
+
+  " inclusive motion
+  exe ":norm! \<c-v>e3jy"
+  call assert_equal([0, 4, 4, 0], getpos("'>"))
+  " exclusive motion
+  exe ":norm! \<c-v>ta3jy"
+  call assert_equal([0, 4, 5, 0], getpos("'>"))
+  " another inclusive motion
+  exe ":norm! \<c-v>g_3jy"
+  call assert_equal([0, 4, 9, 0], getpos("'>"))
+  bwipe!
+  set selection&vim
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index b52eaaeda..1bf116308 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    938,
 /**/
     937,
 /**/

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1tNJ8G-00121k-0B%40256bit.org.

Raspunde prin e-mail lui