Mercurial > vim
diff src/normal.c @ 17984:2ea47dee7ddd v8.1.1988
patch 8.1.1988: :startinsert! does not work the same way as "A"
Commit: https://github.com/vim/vim/commit/8d3b51084a5bdcd2ee9e31bc03cba0d16c43d428
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 5 21:29:01 2019 +0200
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 https://github.com/vim/vim/issues/4896)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 05 Sep 2019 21:30:03 +0200 |
parents | 92e0996e1cb8 |
children | af0b4ffab794 |
line wrap: on
line diff
--- 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 */