mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00: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:
@@ -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;
|
curwin->w_cursor.col -= first_byte_off;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
linenr_T new_lnum = new_cursor.lnum;
|
||||||
|
|
||||||
// Insert at least one line. When y_type is kMTCharWise, break the first
|
// Insert at least one line. When y_type is kMTCharWise, break the first
|
||||||
// line in two.
|
// line in two.
|
||||||
for (cnt = 1; cnt <= count; cnt++) {
|
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);
|
STRCAT(newp, ptr);
|
||||||
// insert second line
|
// insert second line
|
||||||
ml_append(lnum, newp, (colnr_T)0, false);
|
ml_append(lnum, newp, (colnr_T)0, false);
|
||||||
|
new_lnum++;
|
||||||
xfree(newp);
|
xfree(newp);
|
||||||
|
|
||||||
oldp = ml_get(lnum);
|
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++) {
|
for (; i < y_size; i++) {
|
||||||
if ((y_type != kMTCharWise || i < y_size - 1)
|
if ((y_type != kMTCharWise || i < y_size - 1)) {
|
||||||
&& ml_append(lnum, y_array[i], (colnr_T)0, false)
|
if (ml_append(lnum, y_array[i], (colnr_T)0, false) == FAIL) {
|
||||||
== FAIL) {
|
goto error;
|
||||||
goto error;
|
}
|
||||||
|
new_lnum++;
|
||||||
}
|
}
|
||||||
lnum++;
|
lnum++;
|
||||||
++nr_lines;
|
++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,
|
extmark_splice(curbuf, (int)new_cursor.lnum-1, col + 1, 0, 0, 0,
|
||||||
(int)y_size+1, 0, totsize+2, kExtmarkUndo);
|
(int)y_size+1, 0, totsize+2, kExtmarkUndo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cnt == 1) {
|
||||||
|
new_lnum = lnum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@@ -3606,7 +3614,7 @@ error:
|
|||||||
}
|
}
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
} else {
|
} else {
|
||||||
curwin->w_cursor.lnum = lnum;
|
curwin->w_cursor.lnum = new_lnum;
|
||||||
curwin->w_cursor.col = col;
|
curwin->w_cursor.col = col;
|
||||||
}
|
}
|
||||||
} else if (y_type == kMTLineWise) {
|
} else if (y_type == kMTLineWise) {
|
||||||
|
@@ -112,6 +112,16 @@ func Test_put_p_indent_visual()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
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()
|
func Test_multibyte_op_end_mark()
|
||||||
new
|
new
|
||||||
call setline(1, 'тест')
|
call setline(1, 'тест')
|
||||||
|
Reference in New Issue
Block a user