Skip to content

Commit 9b8c8f5

Browse files
committed
updated for version 7.4.034
Problem: Using "p" in Visual block mode only changes the first line. Solution: Repeat the put in all text in the block. (Christian Brabandt)
1 parent ac1c59e commit 9b8c8f5

File tree

6 files changed

+55
-19
lines changed

6 files changed

+55
-19
lines changed

runtime/doc/change.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,11 @@ another register. E.g., yank the text to copy, Visually select the text to
10691069
replace and use "0p . You can repeat this as many times as you like, the
10701070
unnamed register will be changed each time.
10711071

1072+
When you use a blockwise Visual mode command and yank only a single line into
1073+
a register, a paste on a visual selected area will paste that single line on
1074+
each of the selected lines (thus replacing the blockwise selected region by a
1075+
block of the pasted line).
1076+
10721077
*blockwise-register*
10731078
If you use a blockwise Visual mode command to get the text into the register,
10741079
the block of text will be inserted before ("P") or after ("p") the cursor

src/normal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9518,6 +9518,8 @@ nv_put(cap)
95189518
/* cursor is at the end of the line or end of file, put
95199519
* forward. */
95209520
dir = FORWARD;
9521+
/* May have been reset in do_put(). */
9522+
VIsual_active = TRUE;
95219523
}
95229524
#endif
95239525
do_put(cap->oap->regname, dir, cap->count1, flags);

src/ops.c

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3776,25 +3776,42 @@ do_put(regname, dir, count, flags)
37763776
*/
37773777
if (y_type == MCHAR && y_size == 1)
37783778
{
3779-
totlen = count * yanklen;
3780-
if (totlen)
3781-
{
3782-
oldp = ml_get(lnum);
3783-
newp = alloc_check((unsigned)(STRLEN(oldp) + totlen + 1));
3784-
if (newp == NULL)
3785-
goto end; /* alloc() will give error message */
3786-
mch_memmove(newp, oldp, (size_t)col);
3787-
ptr = newp + col;
3788-
for (i = 0; i < count; ++i)
3779+
do {
3780+
totlen = count * yanklen;
3781+
if (totlen > 0)
37893782
{
3790-
mch_memmove(ptr, y_array[0], (size_t)yanklen);
3791-
ptr += yanklen;
3783+
oldp = ml_get(lnum);
3784+
newp = alloc_check((unsigned)(STRLEN(oldp) + totlen + 1));
3785+
if (newp == NULL)
3786+
goto end; /* alloc() gave an error message */
3787+
mch_memmove(newp, oldp, (size_t)col);
3788+
ptr = newp + col;
3789+
for (i = 0; i < count; ++i)
3790+
{
3791+
mch_memmove(ptr, y_array[0], (size_t)yanklen);
3792+
ptr += yanklen;
3793+
}
3794+
STRMOVE(ptr, oldp + col);
3795+
ml_replace(lnum, newp, FALSE);
3796+
/* Place cursor on last putted char. */
3797+
if (lnum == curwin->w_cursor.lnum)
3798+
curwin->w_cursor.col += (colnr_T)(totlen - 1);
37923799
}
3793-
STRMOVE(ptr, oldp + col);
3794-
ml_replace(lnum, newp, FALSE);
3795-
/* Put cursor on last putted char. */
3796-
curwin->w_cursor.col += (colnr_T)(totlen - 1);
3797-
}
3800+
#ifdef FEAT_VISUAL
3801+
if (VIsual_active)
3802+
lnum++;
3803+
#endif
3804+
} while (
3805+
#ifdef FEAT_VISUAL
3806+
VIsual_active && lnum <= curbuf->b_visual.vi_end.lnum
3807+
#else
3808+
FALSE /* stop after 1 paste */
3809+
#endif
3810+
);
3811+
#ifdef FEAT_VISUAL
3812+
VIsual_active = FALSE;
3813+
#endif
3814+
37983815
curbuf->b_op_end = curwin->w_cursor;
37993816
/* For "CTRL-O p" in Insert mode, put cursor after last char */
38003817
if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))

src/testdir/test20.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ G0"ay$k@au
99
@auY:quit!
1010
GP
1111
/start here$
12-
jjlld
13-
:/here$/,$-1w! test.out
12+
"by$jjlld
13+
/456$
14+
jj"bP
15+
:/56$/,$-1w! test.out
1416
:qa!
1517
ENDTEST
1618

19+
123456
20+
234567
21+
345678
22+
1723
test text test tex start here
1824
some text
1925
test text

src/testdir/test20.ok

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
123start here56
2+
234start here67
3+
345start here78
4+
15
test text test tex rt here
26
somext
37
tesext

src/version.c

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

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
34,
741743
/**/
742744
33,
743745
/**/

0 commit comments

Comments
 (0)