v_p split line at unexpected place when replacing last character with line register.
Steps to reproduce: $ vim -u NONE iaaa bbb ccc<Esc>ggYj$vp Result: 1 aaa 2 b 3 aaa 4 b 5 ccc Expected: 1 aaa 2 bb 3 aaa 4 5 ccc I wrote patch for this problem. Please check the attached patch. With this patch, this command $ vim -u NONE iaaa bbb ccc<Esc>ggYG$v$p results 1 aaa 2 bbb 3 cc 4 aaa 5 [empty line] I'm not sure the empty line should be appended or not when newline is selected at last line. -- Yukihiro Nakadaira - yukihiro.nakada...@gmail.com -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
diff -r 18d84ed365a5 src/ops.c --- a/src/ops.c Wed Apr 22 22:18:22 2015 +0200 +++ b/src/ops.c Sat May 23 09:53:11 2015 +0900 @@ -3488,17 +3488,26 @@ { if (flags & PUT_LINE_SPLIT) { + char_u *p; + /* "p" or "P" in Visual mode: split the lines to put the text in * between. */ if (u_save_cursor() == FAIL) goto end; - ptr = vim_strsave(ml_get_cursor()); + p = ml_get_cursor(); + if (dir == FORWARD && *p != NUL) + mb_ptr_adv(p); + ptr = vim_strsave(p); if (ptr == NULL) goto end; ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE); vim_free(ptr); - ptr = vim_strnsave(ml_get_curline(), curwin->w_cursor.col); + oldp = ml_get_curline(); + p = oldp + curwin->w_cursor.col; + if (dir == FORWARD && *p != NUL) + mb_ptr_adv(p); + ptr = vim_strnsave(oldp, p - oldp); if (ptr == NULL) goto end; ml_replace(curwin->w_cursor.lnum, ptr, FALSE); diff -r 18d84ed365a5 src/testdir/test94.in --- a/src/testdir/test94.in Wed Apr 22 22:18:22 2015 +0200 +++ b/src/testdir/test94.in Sat May 23 09:53:11 2015 +0900 @@ -64,6 +64,42 @@ d: :set ma | put = v:errmsg =~# '^E21' ? 'ok' : 'failed' dv:dV::set noma | let v:errmsg = '' d::set ma | put = v:errmsg =~# '^E21' ? 'failed' : 'ok' +: +:$put ='' +:$put ='v_p: replace last character with line register at middle line' +:$put ='aaa' +:$put ='bbb' +:$put ='ccc' +:-2yank +k$vp +:$put ='---' +: +:$put ='' +:$put ='v_p: replace last character with line register at middle line selecting newline' +:$put ='aaa' +:$put ='bbb' +:$put ='ccc' +:-2yank +k$v$p +:$put ='---' +: +:$put ='' +:$put ='v_p: replace last character with line register at last line' +:$put ='aaa' +:$put ='bbb' +:$put ='ccc' +:-2yank +$vp +:$put ='---' +: +:$put ='' +:$put ='v_p: replace last character with line register at last line selecting newline' +:$put ='aaa' +:$put ='bbb' +:$put ='ccc' +:-2yank +$v$p +:$put ='---' :/^start:/+2,$w! test.out :q! ENDTEST diff -r 18d84ed365a5 src/testdir/test94.ok --- a/src/testdir/test94.ok Wed Apr 22 22:18:22 2015 +0200 +++ b/src/testdir/test94.ok Sat May 23 09:53:11 2015 +0900 @@ -18,3 +18,34 @@ zzz ok ok + +v_p: replace last character with line register at middle line +aaa +bb +aaa + +ccc +--- + +v_p: replace last character with line register at middle line selecting newline +aaa +bb +aaa +ccc +--- + +v_p: replace last character with line register at last line +aaa +bbb +cc +aaa + +--- + +v_p: replace last character with line register at last line selecting newline +aaa +bbb +cc +aaa + +---