Bram,
attached patch fixes this bug. See commit message for analysis of the 
error.

On So, 17 Sep 2017, wes1138 wrote:

> To reproduce:
> 
> `$ echo 'asdfasdfasdf' > file`
> `$ vim -c 'startinsert!' file`
> 
> Then observe that cursor is at column 1, contrary to the documentation (and 
> prior behavior).
> This happens with vim built from git yesterday, but also the current version 
> in the Arch Linux repos (8.0.1092).
> 

Christian
-- 
Für Heuchelei gibt's Geld genug. Wahrheit geht betteln.
                -- Martin Luther

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
From 76302e633ad32505a0a34aa5c1ec3ef31cfcf26c Mon Sep 17 00:00:00 2001
From: Christian Brabandt <[email protected]>
Date: Mon, 25 Sep 2017 15:59:12 +0200
Subject: [PATCH] Make :starti! appending again

This was fixed in 6de5e126018b6f9252679 where the cursor column was
unconditionally set to zero if the cursor line is 0.
Unfortunately, this breaks :startinsert! when used in startup commands,
because `exe_commands()` sets the cursor line intentionally to zero, so
that vim +/foobar will find a match on the first line.

So vim -c ':startinsert!' would use line number zero and max column
available, which would then later be overwritten in do_one_cmd.
Therefore, in ex_startinsert explicitly set the cursor line to one, if
it was zero.

Add a test to verify the behaviour.
---
 src/ex_docmd.c               |  3 +++
 src/testdir/test_startup.vim | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index c740d037f..e2dfd9225 100644
--- 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
index af2b3c1d4..f58103ba6 100644
--- 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("ifoobar\<c-o>:wq\<cr>","t")'
+	\ ]
+  if RunVim([], after, 'Xtestout')
+    let lines = readfile('Xtestout')
+    call assert_equal(['ifoobar123456'], lines)
+  endif
+  " Test :startinsert!
+  call writefile(['123456'], 'Xtestout')
+  let after = [
+	\ ':startinsert!',
+  \ 'call feedkeys("ifoobar\<c-o>:wq\<cr>","t")'
+	\ ]
+  if RunVim([], after, 'Xtestout')
+    let lines = readfile('Xtestout')
+    call assert_equal(['123456ifoobar'], lines)
+  endif
+  call delete('Xtestout')
+endfunc
-- 
2.14.1

Raspunde prin e-mail lui