# HG changeset patch # User Christian Brabandt # Date 1506440704 -7200 # Node ID 241fbf588b95ad3994b202b12a940b832d32e96b # Parent cc430340048d2ec7c7f553f7ccebf8f0479ec3ea patch 8.0.1151: "vim -c startinsert!" doesn't append commit https://github.com/vim/vim/commit/09ca932f8e7d63a83b39baa7c03d4c6145e3baab Author: Bram Moolenaar Date: Tue Sep 26 17:40:45 2017 +0200 patch 8.0.1151: "vim -c startinsert!" doesn't append Problem: "vim -c startinsert!" doesn't append. Solution: Correct line number on startup. (Christian Brabandt, closes https://github.com/vim/vim/issues/2117) diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -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; diff --git a/src/testdir/test_startup.vim b/src/testdir/test_startup.vim --- a/src/testdir/test_startup.vim +++ b/src/testdir/test_startup.vim @@ -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\:wq\","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\:wq\","t")' + \ ] + if RunVim([], after, 'Xtestout') + let lines = readfile('Xtestout') + call assert_equal(['123456foobar'], lines) + endif + call delete('Xtestout') +endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -762,6 +762,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1151, +/**/ 1150, /**/ 1149,