diff options
Diffstat (limited to 'src/normal.c')
-rw-r--r-- | src/normal.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/normal.c b/src/normal.c index 1db1d16ab..7abd3fc99 100644 --- a/src/normal.c +++ b/src/normal.c @@ -8898,6 +8898,27 @@ nv_esc(cmdarg_T *cap) } /* + * 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 */ |