]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1172: when 'selection' is "exclusive" then "1v" is one char short v9.0.1172
authorBram Moolenaar <Bram@vim.org>
Tue, 10 Jan 2023 17:29:29 +0000 (17:29 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 10 Jan 2023 17:29:29 +0000 (17:29 +0000)
Problem:    When 'selection' is "exclusive" then "1v" is one char short.
Solution:   Add one character when 'selection' is "exclusive. (closes #11791)

src/normal.c
src/testdir/test_visual.vim
src/version.c

index cc4e2467fcc5fc0417921859c29b54769f93f37d..c319be599ad7df552400e6ff874a54244bd712e4 100644 (file)
@@ -5472,7 +5472,9 @@ nv_visual(cmdarg_T *cap)
                if (resel_VIsual_line_count <= 1)
                {
                    update_curswant_force();
-                   curwin->w_curswant += resel_VIsual_vcol * cap->count0 - 1;
+                   curwin->w_curswant += resel_VIsual_vcol * cap->count0;
+                   if (*p_sel != 'e')
+                       --curwin->w_curswant;
                }
                else
                    curwin->w_curswant = resel_VIsual_vcol;
index 573a2cf490e6b81eb976348901a7e029bff61433..df781a019763b44a291142d46218e58fd96b62d9 100644 (file)
@@ -1336,6 +1336,18 @@ func Test_visual_reselect_with_count()
   bwipe!
 endfunc
 
+func Test_visual_reselect_exclusive()
+  new
+  call setline(1, ['abcde', 'abcde'])
+  set selection=exclusive
+  normal 1G0viwd
+  normal 2G01vd
+  call assert_equal(['', ''], getline(1, 2))
+
+  set selection&
+  bwipe!
+endfunc
+
 func Test_visual_block_insert_round_off()
   new
   " The number of characters are tuned to fill a 4096 byte allocated block,
index da397ee4b4e4b6872a57ff21b30edc7bca0c3cbc..6ab7b95dec35339db573c738bd80ace41ac9cf4a 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1172,
 /**/
     1171,
 /**/