vim-patch:7.4.743

Problem:    "p" in Visual mode causes an unexpected line split.
Solution:   Advance the cursor first. (Yukihiro Nakadaira)

c004bc2726
This commit is contained in:
watiko
2016-02-07 12:12:07 +09:00
parent 4a0e10fb2c
commit 663e1ed158
3 changed files with 83 additions and 9 deletions

View File

@@ -2664,17 +2664,27 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
if (y_type == MLINE) { if (y_type == MLINE) {
if (flags & PUT_LINE_SPLIT) { if (flags & PUT_LINE_SPLIT) {
/* "p" or "P" in Visual mode: split the lines to put the text in // "p" or "P" in Visual mode: split the lines to put the text in
* between. */ // between.
if (u_save_cursor() == FAIL) if (u_save_cursor() == FAIL) {
goto end; goto end;
ptr = vim_strsave(get_cursor_pos_ptr()); }
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE); char_u *p = get_cursor_pos_ptr();
if (dir == FORWARD && *p != NUL) {
mb_ptr_adv(p);
}
ptr = vim_strsave(p);
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, false);
xfree(ptr); xfree(ptr);
ptr = vim_strnsave(get_cursor_line_ptr(), curwin->w_cursor.col); oldp = get_cursor_line_ptr();
ml_replace(curwin->w_cursor.lnum, ptr, FALSE); p = oldp + curwin->w_cursor.col;
++nr_lines; if (dir == FORWARD && *p != NUL) {
mb_ptr_adv(p);
}
ptr = vim_strnsave(oldp, p - oldp);
ml_replace(curwin->w_cursor.lnum, ptr, false);
nr_lines++;
dir = FORWARD; dir = FORWARD;
} }
if (flags & PUT_LINE_FORWARD) { if (flags & PUT_LINE_FORWARD) {

View File

@@ -545,7 +545,7 @@ static int included_patches[] = {
746, 746,
745, 745,
// 744 NA // 744 NA
// 743, 743,
742, 742,
741, 741,
740, 740,

View File

@@ -31,6 +31,13 @@ local function put_abc()
$put ='c']]) $put ='c']])
end end
local function put_aaabbbccc()
source([[
$put ='aaa'
$put ='bbb'
$put ='ccc']])
end
local function define_select_mode_maps() local function define_select_mode_maps()
source([[ source([[
snoremap <lt>End> <End> snoremap <lt>End> <End>
@@ -307,4 +314,61 @@ describe('Visual mode and operator', function()
a]]) a]])
end) end)
end) end)
describe('v_p:', function()
it('replace last character with line register at middle line', function()
put_aaabbbccc()
execute('-2yank')
feed('k$vp')
expect([[
aaa
bb
aaa
ccc]])
end)
it('replace last character with line register at middle line selecting newline', function()
put_aaabbbccc()
execute('-2yank')
feed('k$v$p')
expect([[
aaa
bb
aaa
ccc]])
end)
it('replace last character with line register at last line', function()
put_aaabbbccc()
execute('-2yank')
feed('$vp')
expect([[
aaa
bbb
cc
aaa
]])
end)
it('replace last character with line register at last line selecting newline', function()
put_aaabbbccc()
execute('-2yank')
feed('$v$p')
expect([[
aaa
bbb
cc
aaa
]])
end)
end)
end) end)