To: vim_dev@googlegroups.com Subject: Patch 8.2.0769 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0769 Problem: VimLeavePre not triggered when Vim is terminated. Solution: Unblock autocommands. Files: src/main.c, src/testdir/test_signals.vim *** ../vim-8.2.0768/src/main.c 2020-05-12 22:21:18.444836392 +0200 --- src/main.c 2020-05-16 15:48:32.501755820 +0200 *************** *** 1576,1581 **** --- 1576,1582 ---- tabpage_T *next_tp; buf_T *buf; win_T *wp; + int unblock = 0; // Trigger BufWinLeave for all windows, but only once per buffer. for (tp = first_tabpage; tp != NULL; tp = next_tp) *************** *** 1617,1623 **** --- 1618,1634 ---- // autocmd deleted the buffer break; } + + // deathtrap() blocks autocommands, but we do want to trigger + // VimLeavePre. + if (is_autocmd_blocked()) + { + unblock_autocmds(); + ++unblock; + } apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf); + if (unblock) + block_autocmds(); } #ifdef FEAT_VIMINFO *** ../vim-8.2.0768/src/testdir/test_signals.vim 2020-05-13 16:53:43.514247289 +0200 --- src/testdir/test_signals.vim 2020-05-16 16:05:46.987137039 +0200 *************** *** 127,134 **** if cmd =~ 'valgrind' throw 'Skipped: cannot test signal TERM with valgrind' endif ! let buf = RunVimInTerminal('Xsig_TERM', {'rows': 6}) let pid_vim = term_getjob(buf)->job_info().process call term_sendkeys(buf, ":call setline(1, 'foo')\n") --- 127,139 ---- if cmd =~ 'valgrind' throw 'Skipped: cannot test signal TERM with valgrind' endif + let lines =<< trim END + au VimLeave * call writefile(["VimLeave triggered"], "XautoOut", "a") + au VimLeavePre * call writefile(["VimLeavePre triggered"], "XautoOut", "a") + END + call writefile(lines, 'XsetupAucmd') ! let buf = RunVimInTerminal('-S XsetupAucmd Xsig_TERM', {'rows': 6}) let pid_vim = term_getjob(buf)->job_info().process call term_sendkeys(buf, ":call setline(1, 'foo')\n") *************** *** 145,152 **** --- 150,163 ---- silent recover .Xsig_TERM.swp call assert_equal(['foo'], getline(1, '$')) + let result = readfile('XautoOut') + call assert_match('VimLeavePre triggered', result[0]) + call assert_match('VimLeave triggered', result[1]) + %bwipe! call delete('.Xsig_TERM.swp') + call delete('XsetupAucmd') + call delete('XautoOut') endfunc " vim: ts=8 sw=2 sts=2 tw=80 fdm=marker *** ../vim-8.2.0768/src/version.c 2020-05-16 15:43:26.694803322 +0200 --- src/version.c 2020-05-16 15:53:05.276833463 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 769, /**/ -- hundred-and-one symptoms of being an internet addict: 107. When using your phone you forget that you don't have to use your keyboard. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///