]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1167: mark '] wrong after copying text object v9.1.1167
authorJim Zhou <jimzhouzzy@gmail.com>
Mon, 3 Mar 2025 18:53:26 +0000 (19:53 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 3 Mar 2025 18:58:25 +0000 (19:58 +0100)
Problem:  mark '] wrong after copying text object (ubaldot)
Solution: Adjust position of '] for non-linewise, exclusive motions
          (Jim Zhou)

related: #16679
closes: #16772

Signed-off-by: Jim Zhou <jimzhouzzy@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/register.c
src/testdir/test_registers.vim
src/version.c

index 465bee3bed6c07c011801dd5dda4962ef8923a61..7ba69be06841e61d9ee8d69df9cf43cef917f41f 100644 (file)
@@ -1374,6 +1374,9 @@ op_yank(oparg_T *oap, int deleting, int mess)
            curbuf->b_op_start.col = 0;
            curbuf->b_op_end.col = MAXCOL;
        }
+       if (yanktype != MLINE && !oap->inclusive)
+           // Exclude the end position.
+           decl(&curbuf->b_op_end);
     }
 
 #ifdef FEAT_CLIPBOARD
index 43f80be29982ba22298a3f7cc51264640c79533a..0ff1df84cf262727e342ca951e0f76f68a2476f9 100644 (file)
@@ -1154,4 +1154,54 @@ func Test_register_cursor_column_negative()
   call StopVimInTerminal(buf)
 endfunc
 
+" test '] mark generated by op_yank
+func Test_mark_from_yank()
+  new
+  " double quote object
+  call setline(1, 'test "yank"  mark')
+  normal! yi"
+  call assert_equal([0, 1, 10, 0], getpos("']"))
+  normal! ya"
+  call assert_equal(getpos("']"), [0, 1, 13, 0], getpos("']"))
+  " single quote object
+  call setline(1, 'test ''yank''  mark')
+  normal! yi'
+  call assert_equal([0, 1, 10, 0], getpos("']"))
+  normal! ya'
+  call assert_equal([0, 1, 13, 0], getpos("']"))
+  " paren object
+  call setline(1, 'test (yank)  mark')
+  call cursor(1, 9)
+  normal! yi(
+  call assert_equal([0, 1, 10, 0], getpos("']"))
+  call cursor(1, 9)
+  normal! ya(
+  call assert_equal([0, 1, 11, 0], getpos("']"))
+  " brace object
+  call setline(1, 'test {yank}  mark')
+  call cursor(1, 9)
+  normal! yi{
+  call assert_equal([0, 1, 10, 0], getpos("']"))
+  call cursor(1, 9)
+  normal! ya{
+  call assert_equal([0, 1, 11, 0], getpos("']"))
+  " bracket object
+  call setline(1, 'test [yank]  mark')
+  call cursor(1, 9)
+  normal! yi[
+  call assert_equal([0, 1, 10, 0], getpos("']"))
+  call cursor(1, 9)
+  normal! ya[
+  call assert_equal([0, 1, 11, 0], getpos("']"))
+  " block object
+  call setline(1, 'test <yank>  mark')
+  call cursor(1, 9)
+  normal! yi<
+  call assert_equal([0, 1, 10, 0], getpos("']"))
+  call cursor(1, 9)
+  normal! ya<
+  call assert_equal([0, 1, 11, 0], getpos("']"))
+  bw!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 34459ef01ea296e7106104ade0be1a937fb076a1..29ea4beef689d17085f37babcd64a79d93dc673b 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1167,
 /**/
     1166,
 /**/