}
else
{
+ linenr_T new_lnum = new_cursor.lnum;
+
// Insert at least one line. When y_type is MCHAR, break the first
// line in two.
for (cnt = 1; cnt <= count; ++cnt)
STRCAT(newp, ptr);
// insert second line
ml_append(lnum, newp, (colnr_T)0, FALSE);
+ ++new_lnum;
vim_free(newp);
oldp = ml_get(lnum);
for (; i < y_size; ++i)
{
- if ((y_type != MCHAR || i < y_size - 1)
- && ml_append(lnum, y_array[i], (colnr_T)0, FALSE)
+ if (y_type != MCHAR || i < y_size - 1)
+ {
+ if (ml_append(lnum, y_array[i], (colnr_T)0, FALSE)
== FAIL)
goto error;
+ new_lnum++;
+ }
lnum++;
++nr_lines;
if (flags & PUT_FIXINDENT)
lendiff -= (int)STRLEN(ml_get(lnum));
}
}
+ if (cnt == 1)
+ new_lnum = lnum;
}
error:
}
else
{
- curwin->w_cursor.lnum = lnum;
+ curwin->w_cursor.lnum = new_lnum;
curwin->w_cursor.col = col;
}
}
close!
endfunc
+func Test_gp_with_count_leaves_cursor_at_end()
+ new
+ call setline(1, '<---->')
+ call setreg('@', "foo\nbar", 'c')
+ exe "normal 1G3|3gpix\<Esc>"
+ call assert_equal(['<--foo', 'barfoo', 'barfoo', 'barx-->'], getline(1, '$'))
+
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab