changeset 26012:b863efc63397 v8.2.3540

patch 8.2.3540: the mark '] is wrong after put with a count Commit: https://github.com/vim/vim/commit/f47ebf1e1a0a6473b10fb4c92c9c6427aab4dc91 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Oct 19 20:08:45 2021 +0100 patch 8.2.3540: the mark '] is wrong after put with a count Problem: The mark '] is wrong after put with a count. (Naohiro Ono) Solution: Use the right line number. (closes https://github.com/vim/vim/issues/8956)
author Bram Moolenaar <Bram@vim.org>
date Tue, 19 Oct 2021 21:15:04 +0200
parents 7278258f5f83
children 70ae2f2ee992
files src/register.c src/testdir/test_put.vim src/version.c
diffstat 3 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/register.c
+++ b/src/register.c
@@ -2183,7 +2183,7 @@ error:
 					   curbuf->b_op_start.lnum, nr_lines);
 
 	    // put '] mark at last inserted character
-	    curbuf->b_op_end.lnum = lnum;
+	    curbuf->b_op_end.lnum = new_lnum;
 	    // correct length for change in indent
 	    col = (colnr_T)STRLEN(y_array[y_size - 1]) - lendiff;
 	    if (col > 1)
--- a/src/testdir/test_put.vim
+++ b/src/testdir/test_put.vim
@@ -136,6 +136,18 @@ func Test_gp_with_count_leaves_cursor_at
   bwipe!
 endfunc
 
+func Test_p_with_count_leaves_mark_at_end()
+  new
+  call setline(1, '<---->')
+  call setreg('@', "start\nend", 'c')
+  normal 1G3|3p
+  call assert_equal([0, 1, 4, 0], getpos("."))
+  call assert_equal(['<--start', 'endstart', 'endstart', 'end-->'], getline(1, '$'))
+  call assert_equal([0, 4, 3, 0], getpos("']"))
+
+  bwipe!
+endfunc
+
 func Test_very_large_count()
   " FIXME: should actually check if sizeof(int) == sizeof(long)
   CheckNotMSWindows
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3540,
+/**/
     3539,
 /**/
     3538,