summaryrefslogtreecommitdiff
path: root/src/normal.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-09-05 21:29:01 +0200
committerBram Moolenaar <Bram@vim.org>2019-09-05 21:29:01 +0200
commit8d3b51084a5bdcd2ee9e31bc03cba0d16c43d428 (patch)
tree9d639842238d3d284834750ef03b4bc6e550903e /src/normal.c
parenta0d1fef4ebb693696464c5e22e33269f724b8e0e (diff)
downloadvim-git-8d3b51084a5bdcd2ee9e31bc03cba0d16c43d428.tar.gz
patch 8.1.1988: :startinsert! does not work the same way as "A"v8.1.1988
Problem: :startinsert! does not work the same way as "A". Solution: Use the same code to move the cursor. (closes #4896)
Diffstat (limited to 'src/normal.c')
-rw-r--r--src/normal.c35
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 */