]> granicus.if.org Git - vim/commitdiff
patch 8.2.3540: the mark '] is wrong after put with a count v8.2.3540
authorBram Moolenaar <Bram@vim.org>
Tue, 19 Oct 2021 19:08:45 +0000 (20:08 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 19 Oct 2021 19:08:45 +0000 (20:08 +0100)
Problem:    The mark '] is wrong after put with a count. (Naohiro Ono)
Solution:   Use the right line number. (closes #8956)

src/register.c
src/testdir/test_put.vim
src/version.c

index 9f179ea1518c4ccb6cb99b5f2d3aaab3b62593af..522500ce1d1290144be734e89248fb18727ca640 100644 (file)
@@ -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)
index 4e3294679cb7d7730501056247152eb7938fa37e..a6bed75358ff0ec2e1ea42a866208d7e51828c5a 100644 (file)
@@ -136,6 +136,18 @@ func Test_gp_with_count_leaves_cursor_at_end()
   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
index 28a70fd39c67474cc091dc5a40102c786586dc28..c430ff1702df660fc7854b2328a308af23611a29 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3540,
 /**/
     3539,
 /**/