0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 8.1.1988: :startinsert! does not work the same way as "A"

Problem:    :startinsert! does not work the same way as "A".
Solution:   Use the same code to move the cursor. (closes #4896)
This commit is contained in:
Bram Moolenaar
2019-09-05 21:29:01 +02:00
parent a0d1fef4eb
commit 8d3b51084a
5 changed files with 45 additions and 20 deletions

View File

@@ -8897,6 +8897,27 @@ nv_esc(cmdarg_T *cap)
restart_edit = 'a';
}
/*
* Move the cursor for the "A" command.
*/
void
set_cursor_for_append_to_line(void)
{
curwin->w_set_curswant = TRUE;
if (ve_flags == VE_ALL)
{
int save_State = State;
/* Pretend Insert mode here to allow the cursor on the
* character past the end of the line */
State = INSERT;
coladvance((colnr_T)MAXCOL);
State = save_State;
}
else
curwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor());
}
/*
* Handle "A", "a", "I", "i" and <Insert> commands.
* Also handle K_PS, start bracketed paste.
@@ -8983,19 +9004,7 @@ nv_edit(cmdarg_T *cap)
switch (cap->cmdchar)
{
case 'A': /* "A"ppend after the line */
curwin->w_set_curswant = TRUE;
if (ve_flags == VE_ALL)
{
int save_State = State;
/* Pretend Insert mode here to allow the cursor on the
* character past the end of the line */
State = INSERT;
coladvance((colnr_T)MAXCOL);
State = save_State;
}
else
curwin->w_cursor.col += (colnr_T)STRLEN(ml_get_cursor());
set_cursor_for_append_to_line();
break;
case 'I': /* "I"nsert before the first non-blank */