]> granicus.if.org Git - vim/commitdiff
patch 7.4.1970 v7.4.1970
authorBram Moolenaar <Bram@vim.org>
Fri, 1 Jul 2016 12:04:51 +0000 (14:04 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 1 Jul 2016 12:04:51 +0000 (14:04 +0200)
Problem:    Using ":insert" in an empty buffer sets the jump mark. (Ingo
            Karkat)
Solution:   Don't adjust marks when replacing the empty line in an empty
            buffer. (closes #892)

src/ex_cmds.c
src/testdir/test_alot.vim
src/testdir/test_jumps.vim [new file with mode: 0644]
src/version.c

index f58bad7be13fd3671ff572889a6a6f3251f31fb3..36d7bd19597ffedd1034839182a2e9f9e410b0e2 100644 (file)
@@ -4372,7 +4372,7 @@ ex_append(exarg_T *eap)
     if (eap->cmdidx != CMD_append)
        --lnum;
 
-    /* when the buffer is empty append to line 0 and delete the dummy line */
+    /* when the buffer is empty need to delete the dummy line */
     if (empty && lnum == 1)
        lnum = 0;
 
@@ -4456,7 +4456,7 @@ ex_append(exarg_T *eap)
 
        did_undo = TRUE;
        ml_append(lnum, theline, (colnr_T)0, FALSE);
-       appended_lines_mark(lnum, 1L);
+       appended_lines_mark(lnum + (empty ? 1 : 0), 1L);
 
        vim_free(theline);
        ++lnum;
index 444085e181fefbee988441c7f31c56e9735af6a8..76134fb6678a4781810245d620c7bb87ddbfd438 100644 (file)
@@ -16,6 +16,7 @@ source test_glob2regpat.vim
 source test_goto.vim
 source test_help_tagjump.vim
 source test_join.vim
+source test_jumps.vim
 source test_lispwords.vim
 source test_matchstrpos.vim
 source test_menu.vim
diff --git a/src/testdir/test_jumps.vim b/src/testdir/test_jumps.vim
new file mode 100644 (file)
index 0000000..5a3717d
--- /dev/null
@@ -0,0 +1,11 @@
+func Test_empty_buffer()
+  new
+  insert
+a
+b
+c
+d
+.
+  call assert_equal(1, line("''"))
+  bwipe!
+endfunc
index 8e9da45f831f580cb868725ba218b37ed804035f..774d309d379e8a51ab0646c2b24197963f500e0b 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1970,
 /**/
     1969,
 /**/