Skip to content
Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brammool committed Oct 15, 2022
1 parent c8b6735 commit 36343ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/register.c
Expand Up @@ -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)
{
Expand Down
12 changes: 12 additions & 0 deletions src/testdir/test_visual.vim
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
765,
/**/
764,
/**/
Expand Down

0 comments on commit 36343ae

Please sign in to comment.