]> granicus.if.org Git - vim/commitdiff
patch 8.0.1151: "vim -c startinsert!" doesn't append v8.0.1151
authorBram Moolenaar <Bram@vim.org>
Tue, 26 Sep 2017 15:40:45 +0000 (17:40 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 26 Sep 2017 15:40:45 +0000 (17:40 +0200)
Problem:    "vim -c startinsert!" doesn't append.
Solution:   Correct line number on startup. (Christian Brabandt, closes #2117)

src/ex_docmd.c
src/testdir/test_startup.vim
src/version.c

index c740d037f55498eab4946ec5d5b65a81675b89c7..e2dfd9225cba27c04d18d311ac71727449c3d65d 100644 (file)
@@ -10294,6 +10294,9 @@ ex_startinsert(exarg_T *eap)
 {
     if (eap->forceit)
     {
+       /* cursor line can be zero on startup */
+       if (!curwin->w_cursor.lnum)
+           curwin->w_cursor.lnum = 1;
        coladvance((colnr_T)MAXCOL);
        curwin->w_curswant = MAXCOL;
        curwin->w_set_curswant = FALSE;
index af2b3c1d4fa4a3fa58643cbb2133e536321d45b2..6f67bfc11b9c3482598d23b564bdc368b444f082 100644 (file)
@@ -263,3 +263,27 @@ func Test_default_term()
   call assert_match("defaulting to 'ansi'", out)
   let $TERM = save_term
 endfunc
+
+func Test_zzz_startinsert()
+  " Test :startinsert
+  call writefile(['123456'], 'Xtestout')
+  let after = [
+       \ ':startinsert',
+  \ 'call feedkeys("foobar\<c-o>:wq\<cr>","t")'
+       \ ]
+  if RunVim([], after, 'Xtestout')
+    let lines = readfile('Xtestout')
+    call assert_equal(['foobar123456'], lines)
+  endif
+  " Test :startinsert!
+  call writefile(['123456'], 'Xtestout')
+  let after = [
+       \ ':startinsert!',
+  \ 'call feedkeys("foobar\<c-o>:wq\<cr>","t")'
+       \ ]
+  if RunVim([], after, 'Xtestout')
+    let lines = readfile('Xtestout')
+    call assert_equal(['123456foobar'], lines)
+  endif
+  call delete('Xtestout')
+endfunc
index e96e77b37bdac005099f2ddb361ce8033e6fbf82..f948b8e3070c5dc6a7de6792a465c341f08c27f1 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1151,
 /**/
     1150,
 /**/