Skip to content

Commit 9957a10

Browse files
committed
patch 8.0.0225: put in Visual block mode terminates early
Problem: When a block is visually selected and put is used on the end of the selection only one line is changed. Solution: Check for the end properly. (Christian Brabandt, neovim issue 5781)
1 parent 7a2699e commit 9957a10

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/ops.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3774,6 +3774,11 @@ do_put(
37743774
*/
37753775
if (y_type == MCHAR && y_size == 1)
37763776
{
3777+
linenr_T end = curbuf->b_visual.vi_end.lnum;
3778+
3779+
if (curbuf->b_visual.vi_end.lnum < curbuf->b_visual.vi_start.lnum)
3780+
end = curbuf->b_visual.vi_start.lnum;
3781+
37773782
do {
37783783
totlen = count * yanklen;
37793784
if (totlen > 0)
@@ -3801,7 +3806,7 @@ do_put(
38013806
}
38023807
if (VIsual_active)
38033808
lnum++;
3804-
} while (VIsual_active && lnum <= curbuf->b_visual.vi_end.lnum);
3809+
} while (VIsual_active && lnum <= end);
38053810

38063811
if (VIsual_active) /* reset lnum to the last visual line */
38073812
lnum--;

src/testdir/test_put.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,14 @@ func Test_put_block()
1010
call assert_equal("\u2500x", getline(1))
1111
bwipe!
1212
endfunc
13+
14+
func Test_put_char_block()
15+
new
16+
call setline(1, ['Line 1', 'Line 2'])
17+
f Xfile_put
18+
" visually select both lines and put the cursor at the top of the visual
19+
" selection and then put the buffer name over it
20+
exe "norm! G0\<c-v>ke\"%p"
21+
call assert_equal(['Xfile_put 1', 'Xfile_put 2'], getline(1,2))
22+
bw!
23+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
225,
767769
/**/
768770
224,
769771
/**/

0 commit comments

Comments
 (0)