aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 7279110444..4d487041b8 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1392,11 +1392,20 @@ ins_redraw (
&& !pum_visible()) {
aco_save_T aco;
+ // Sync undo when the autocommand calls setline() or append(), so that
+ // it can be undone separately.
+ u_sync_once = 2;
+
// save and restore curwin and curbuf, in case the autocmd changes them
aucmd_prepbuf(&aco, curbuf);
apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, false, curbuf);
aucmd_restbuf(&aco);
curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
+
+ if (u_sync_once == 1) {
+ ins_need_undo = true;
+ }
+ u_sync_once = 0;
}
// Trigger TextChangedP if changedtick differs. When the popupmenu closes