changeset 30861:c33f094d20c1 v9.0.0765

patch 9.0.0765: with a Visual block a put command column may go negative Commit: https://github.com/vim/vim/commit/36343ae0fb7247e060abfd35fb8e4337b33abb4b Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 15 19:04:05 2022 +0100 patch 9.0.0765: with a Visual block a put command column may go negative Problem: With a Visual block a put command column may go negative. Solution: Check that the column does not become negative.
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Oct 2022 20:15:05 +0200
parents 2fc7ab54b114
children 2040ac6761ba
files src/register.c src/testdir/test_visual.vim src/version.c
diffstat 3 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/register.c
+++ b/src/register.c
@@ -1960,6 +1960,8 @@ do_put(
 	// adjust '] mark
 	curbuf->b_op_end.lnum = curwin->w_cursor.lnum - 1;
 	curbuf->b_op_end.col = bd.textcol + totlen - 1;
+	if (curbuf->b_op_end.col < 0)
+	    curbuf->b_op_end.col = 0;
 	curbuf->b_op_end.coladd = 0;
 	if (flags & PUT_CURSEND)
 	{
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -483,6 +483,18 @@ func Test_visual_block_put()
   bw!
 endfunc
 
+func Test_visual_block_put_invalid()
+  enew!
+  behave mswin
+  norm yy
+  norm v)Ps/^/	
+  " this was causing the column to become negative
+  silent norm ggv)P
+
+  bwipe!
+  behave xterm
+endfunc
+
 " Visual modes (v V CTRL-V) followed by an operator; count; repeating
 func Test_visual_mode_op()
   new
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    765,
+/**/
     764,
 /**/
     763,