summaryrefslogtreecommitdiffstats
path: root/src/edit.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-12-08 21:49:35 +0000
committerBram Moolenaar <Bram@vim.org>2022-12-08 21:49:35 +0000
commit3f8f82772313af9f2417b06651f30988b63e1c96 (patch)
treebcb39bcc4421135334decdea16a3dc176c6afe94 /src/edit.c
parentd28d7b94f5a76a817585c115dbf6fecac9b0b4cd (diff)
patch 9.0.1036: undo misbehaves when writing from an insert mode mappingv9.0.1036
Problem: Undo misbehaves when writing from an insert mode mapping. Solution: Sync undo when writing. (closes #11674)
Diffstat (limited to 'src/edit.c')
-rw-r--r--src/edit.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/edit.c b/src/edit.c
index 43f7d9abb0..9e8346d1c2 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1049,12 +1049,19 @@ doESCkey:
case K_COMMAND: // <Cmd>command<CR>
case K_SCRIPT_COMMAND: // <ScriptCmd>command<CR>
- do_cmdkey_command(c, 0);
+ {
+ do_cmdkey_command(c, 0);
+
#ifdef FEAT_TERMINAL
- if (term_use_loop())
- // Started a terminal that gets the input, exit Insert mode.
- goto doESCkey;
+ if (term_use_loop())
+ // Started a terminal that gets the input, exit Insert mode.
+ goto doESCkey;
#endif
+ if (curbuf->b_u_synced)
+ // The command caused undo to be synced. Need to save the
+ // line for undo before inserting the next char.
+ ins_need_undo = TRUE;
+ }
break;
case K_CURSORHOLD: // Didn't type something for a while.