Skip to content

Commit 09ca932

Browse files
committed
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 #2117)
1 parent 6edeaf3 commit 09ca932

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/ex_docmd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10294,6 +10294,9 @@ ex_startinsert(exarg_T *eap)
1029410294
{
1029510295
if (eap->forceit)
1029610296
{
10297+
/* cursor line can be zero on startup */
10298+
if (!curwin->w_cursor.lnum)
10299+
curwin->w_cursor.lnum = 1;
1029710300
coladvance((colnr_T)MAXCOL);
1029810301
curwin->w_curswant = MAXCOL;
1029910302
curwin->w_set_curswant = FALSE;

src/testdir/test_startup.vim

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,27 @@ func Test_default_term()
263263
call assert_match("defaulting to 'ansi'", out)
264264
let $TERM = save_term
265265
endfunc
266+
267+
func Test_zzz_startinsert()
268+
" Test :startinsert
269+
call writefile(['123456'], 'Xtestout')
270+
let after = [
271+
\ ':startinsert',
272+
\ 'call feedkeys("foobar\<c-o>:wq\<cr>","t")'
273+
\ ]
274+
if RunVim([], after, 'Xtestout')
275+
let lines = readfile('Xtestout')
276+
call assert_equal(['foobar123456'], lines)
277+
endif
278+
" Test :startinsert!
279+
call writefile(['123456'], 'Xtestout')
280+
let after = [
281+
\ ':startinsert!',
282+
\ 'call feedkeys("foobar\<c-o>:wq\<cr>","t")'
283+
\ ]
284+
if RunVim([], after, 'Xtestout')
285+
let lines = readfile('Xtestout')
286+
call assert_equal(['123456foobar'], lines)
287+
endif
288+
call delete('Xtestout')
289+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1151,
764766
/**/
765767
1150,
766768
/**/

0 commit comments

Comments
 (0)