mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.3454: using a count with "gp" leave cursor in wrong position
Problem: Using a count with "gp" leave cursor in wrong position. (Naohiro
Ono)
Solution: Count the inserted lines. (closes vim/vim#8899)
23003e51e1
This commit is contained in:
parent
af9a2a201d
commit
fee7d6fba4
@ -3472,6 +3472,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
||||
curwin->w_cursor.col -= first_byte_off;
|
||||
}
|
||||
} else {
|
||||
linenr_T new_lnum = new_cursor.lnum;
|
||||
|
||||
// Insert at least one line. When y_type is kMTCharWise, break the first
|
||||
// line in two.
|
||||
for (cnt = 1; cnt <= count; cnt++) {
|
||||
@ -3488,6 +3490,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
||||
STRCAT(newp, ptr);
|
||||
// insert second line
|
||||
ml_append(lnum, newp, (colnr_T)0, false);
|
||||
new_lnum++;
|
||||
xfree(newp);
|
||||
|
||||
oldp = ml_get(lnum);
|
||||
@ -3503,10 +3506,11 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
||||
}
|
||||
|
||||
for (; i < y_size; i++) {
|
||||
if ((y_type != kMTCharWise || i < y_size - 1)
|
||||
&& ml_append(lnum, y_array[i], (colnr_T)0, false)
|
||||
== FAIL) {
|
||||
goto error;
|
||||
if ((y_type != kMTCharWise || i < y_size - 1)) {
|
||||
if (ml_append(lnum, y_array[i], (colnr_T)0, false) == FAIL) {
|
||||
goto error;
|
||||
}
|
||||
new_lnum++;
|
||||
}
|
||||
lnum++;
|
||||
++nr_lines;
|
||||
@ -3556,6 +3560,10 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
||||
extmark_splice(curbuf, (int)new_cursor.lnum-1, col + 1, 0, 0, 0,
|
||||
(int)y_size+1, 0, totsize+2, kExtmarkUndo);
|
||||
}
|
||||
|
||||
if (cnt == 1) {
|
||||
new_lnum = lnum;
|
||||
}
|
||||
}
|
||||
|
||||
error:
|
||||
@ -3606,7 +3614,7 @@ error:
|
||||
}
|
||||
curwin->w_cursor.col = 0;
|
||||
} else {
|
||||
curwin->w_cursor.lnum = lnum;
|
||||
curwin->w_cursor.lnum = new_lnum;
|
||||
curwin->w_cursor.col = col;
|
||||
}
|
||||
} else if (y_type == kMTLineWise) {
|
||||
|
@ -112,6 +112,16 @@ func Test_put_p_indent_visual()
|
||||
bwipe!
|
||||
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
|
||||
|
||||
func Test_multibyte_op_end_mark()
|
||||
new
|
||||
call setline(1, 'тест')
|
||||
|
Loading…
Reference in New Issue
Block a user