diff options
author | Bram Moolenaar <Bram@vim.org> | 2015-06-19 15:17:55 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2015-06-19 15:17:55 +0200 |
commit | c004bc2726eafc7a56d1d9f8398a65a0a7dc8d6c (patch) | |
tree | 3a088bdfccf7659d244fc603677f831487c9dbfe | |
parent | a594d77ffcccf2ac0e4079c41342ca55d4c9bb08 (diff) |
patch 7.4.743v7.4.743
Problem: "p" in Visual mode causes an unexpected line split.
Solution: Advance the cursor first. (Yukihiro Nakadaira)
-rw-r--r-- | src/ops.c | 13 | ||||
-rw-r--r-- | src/testdir/test94.in | 36 | ||||
-rw-r--r-- | src/testdir/test94.ok | 31 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 80 insertions, 2 deletions
@@ -3459,17 +3459,26 @@ do_put(regname, dir, count, flags) { 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 --git a/src/testdir/test94.in b/src/testdir/test94.in index e98d58875c..287d9dc9c1 100644 --- a/src/testdir/test94.in +++ b/src/testdir/test94.in @@ -174,6 +174,42 @@ gH<Del> :$put ='c' kgH<Down><Del> :$put ='---' +: +:$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 --git a/src/testdir/test94.ok b/src/testdir/test94.ok index 9207ea5b5e..a1b037813f 100644 --- a/src/testdir/test94.ok +++ b/src/testdir/test94.ok @@ -81,3 +81,34 @@ b linewise select mode: delete last two line a --- + +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 + +--- diff --git a/src/version.c b/src/version.c index 197b6ea0b9..1dcdf71ee2 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 743, +/**/ 742, /**/ 741, |