diff options
| author | Jason Felice <jason.m.felice@gmail.com> | 2018-08-08 16:02:32 -0700 | 
|---|---|---|
| committer | Jason Felice <jason.m.felice@gmail.com> | 2018-08-09 16:46:11 -0700 | 
| commit | d45efa5793e8b60192cc5b1f80d112d0401b14d3 (patch) | |
| tree | 30f68c30c2aa39c9551cac83f1a60de3200b5834 /src/nvim/edit.c | |
| parent | 0a8be9f8ef1e23a375b3a35ec06734f205cfd181 (diff) | |
| download | rneovim-d45efa5793e8b60192cc5b1f80d112d0401b14d3.tar.gz rneovim-d45efa5793e8b60192cc5b1f80d112d0401b14d3.tar.bz2 rneovim-d45efa5793e8b60192cc5b1f80d112d0401b14d3.zip | |
vim-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 vim/vim#3291)
https://github.com/vim/vim/commit/91d2e783b41ca900bc603b3cb5e083c8a4a33170
Diffstat (limited to 'src/nvim/edit.c')
| -rw-r--r-- | src/nvim/edit.c | 9 | 
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 | 
