summaryrefslogtreecommitdiff
path: root/src/edit.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-08-07 19:05:01 +0200
committerBram Moolenaar <Bram@vim.org>2018-08-07 19:05:01 +0200
commit91d2e783b41ca900bc603b3cb5e083c8a4a33170 (patch)
treef42a1d2db656122fb069474859514d9cb62523c4 /src/edit.c
parent917e32bda5a93941fbbccab09ae3960114b67188 (diff)
downloadvim-git-91d2e783b41ca900bc603b3cb5e083c8a4a33170.tar.gz
patch 8.1.0245: calling setline() in TextChangedI autocmd breaks undov8.1.0245
Problem: Calling setline() in TextChangedI autocmd breaks undo. (Jason Felice) Solution: Don't save lines for undo when already saved. (closes #3291)
Diffstat (limited to 'src/edit.c')
-rw-r--r--src/edit.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/edit.c b/src/edit.c
index 45176d79f..b5c129f99 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1722,11 +1722,19 @@ ins_redraw(
{
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 = CHANGEDTICK(curbuf);
+
+ if (u_sync_once == 1)
+ ins_need_undo = TRUE;
+ u_sync_once = 0;
}
#ifdef FEAT_INS_EXPAND