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:
35
src/normal.c
35
src/normal.c
@@ -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 */
|
||||
|
Reference in New Issue
Block a user