Mercurial > vim
diff src/edit.c @ 14463:3b87daa5c37a v8.1.0245
patch 8.1.0245: calling setline() in TextChangedI autocmd breaks undo
commit https://github.com/vim/vim/commit/91d2e783b41ca900bc603b3cb5e083c8a4a33170
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 7 19:05:01 2018 +0200
patch 8.1.0245: calling setline() in TextChangedI autocmd breaks undo
Problem: Calling setline() in TextChangedI autocmd breaks undo. (Jason
Felice)
Solution: Don't save lines for undo when already saved. (closes #3291)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 07 Aug 2018 19:15:05 +0200 |
parents | 893ac612569f |
children | 78d4375b6bb2 |
line wrap: on
line diff
--- 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