summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-16 16:08:35 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-16 16:08:35 +0200
commit129d6bf6b3d120b0a4c69e18b5e8602a84e352bf (patch)
tree0634cab073ab0767b0e99b20a8e72ea8d9121ff9
parente75ba268b35a9b3a1f8b47668e657259555fc5fa (diff)
downloadvim-git-8.2.0769.tar.gz
patch 8.2.0769: VimLeavePre not triggered when Vim is terminatedv8.2.0769
Problem: VimLeavePre not triggered when Vim is terminated. Solution: Unblock autocommands.
-rw-r--r--src/main.c11
-rw-r--r--src/testdir/test_signals.vim13
-rw-r--r--src/version.c2
3 files changed, 25 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index b00d7b987..201ed3721 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1576,6 +1576,7 @@ getout(int exitval)
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,7 +1618,17 @@ getout(int exitval)
// 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
diff --git a/src/testdir/test_signals.vim b/src/testdir/test_signals.vim
index 0008e31fb..48e3a3e0e 100644
--- a/src/testdir/test_signals.vim
+++ b/src/testdir/test_signals.vim
@@ -127,8 +127,13 @@ func Test_deadly_signal_TERM()
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('Xsig_TERM', {'rows': 6})
+ 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,8 +150,14 @@ func Test_deadly_signal_TERM()
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
diff --git a/src/version.c b/src/version.c
index 8c89761bb..a1b038f15 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 769,
+/**/
768,
/**/
767,