]> granicus.if.org Git - vim/commitdiff
patch 7.4.743 v7.4.743
authorBram Moolenaar <Bram@vim.org>
Fri, 19 Jun 2015 13:17:55 +0000 (15:17 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 19 Jun 2015 13:17:55 +0000 (15:17 +0200)
Problem:    "p" in Visual mode causes an unexpected line split.
Solution:   Advance the cursor first. (Yukihiro Nakadaira)

src/ops.c
src/testdir/test94.in
src/testdir/test94.ok
src/version.c

index 05b1e1cc2e43a9099312473e3a444a858712b043..32461a8da61dfcf2cffae29372adb403e0bf70d9 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -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);
index e98d58875ce348f419b3d10f0f37023d8f5e5127..287d9dc9c149cd9aa1c10da35ed58b645d3ed29b 100644 (file)
@@ -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
index 9207ea5b5e402fb19c9f0591b16572b8dc0517ab..a1b037813f8d73352232fa0a014fbdc43363bfb5 100644 (file)
@@ -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
+
+---
index 197b6ea0b917e883cf97d1a1f798fd48e2889432..1dcdf71ee2f6e6d533ed10eb5e8322366df1b2cf 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    743,
 /**/
     742,
 /**/