On Tue, Aug 7, 2018 at 11:00 PM, Christ van Willegen <cvwille...@gmail.com> wrote: > Hi, > > > > Op di 7 aug. 2018 19:05 schreef Bram Moolenaar <b...@moolenaar.net>: >> >> >> Patch 8.1.0245 >> Problem: Calling setline() in TextChangedI autocmd breaks undo. (Jason >> Felice) >> Solution: Don't save lines for undo when already saved. (closes #3291) >> Files: src/edit.c, src/testdir/test_autocmd.vim >> >> >> *** ../vim-8.1.0244/src/edit.c 2018-08-07 14:55:04.905259782 +0200 >> --- src/edit.c 2018-08-07 18:26:35.026760346 +0200 >> *************** >> *** 1722,1732 **** >> --- 1722,1740 ---- >> { >> 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; >> } > > > The "if" condition looks weird. It looks as if the variable u_sync_once is > set to 2 unconditionally, and then tested if it is == 1. I'm probably wrong, > though... > > Christ van Willegen
Three functions are called in between. What do you bet that one or more of them has access by reference to that variable? Best regards, Tony. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.