Skip to content

Commit d41babe

Browse files
committed
patch 8.0.1019: pasting in virtual edit happens in the wrong place
Problem: Pasting in virtual edit happens in the wrong place. Solution: Do not adjust coladd when after the end of the line (closes #2015)
1 parent 4ad3b2b commit d41babe

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/misc2.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,14 @@ check_cursor_col_win(win_T *win)
607607
if (oldcoladd > win->w_cursor.col)
608608
{
609609
win->w_cursor.coladd = oldcoladd - win->w_cursor.col;
610-
if (win->w_cursor.col < len && win->w_cursor.coladd > 0)
610+
611+
/* Make sure that coladd is not more than the char width.
612+
* Not for the last character, coladd is then used when the cursor
613+
* is actually after the last character. */
614+
if (win->w_cursor.col + 1 < len && win->w_cursor.coladd > 0)
611615
{
612616
int cs, ce;
613617

614-
/* check that coladd is not more than the char width */
615618
getvcol(win, &win->w_cursor, &cs, NULL, &ce);
616619
if (win->w_cursor.coladd > ce - cs)
617620
win->w_cursor.coladd = ce - cs;

src/testdir/test_virtualedit.vim

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Tests for 'virtualedit'.
22

33
func Test_yank_move_change()
4-
split
4+
new
55
call setline(1, [
66
\ "func foo() error {",
77
\ "\tif n, err := bar();",
@@ -29,3 +29,15 @@ func Test_yank_move_change()
2929
set virtualedit=
3030
set ts=8
3131
endfunc
32+
33+
func Test_paste_end_of_line()
34+
new
35+
set virtualedit=all
36+
call setline(1, ['456', '123'])
37+
normal! gg0"ay$
38+
exe "normal! 2G$lllA\<C-O>:normal! \"agP\r"
39+
call assert_equal('123456', getline(2))
40+
41+
bwipe!
42+
set virtualedit=
43+
endfunc

src/version.c

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

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
1019,
772774
/**/
773775
1018,
774776
/**/

0 commit comments

Comments
 (0)