aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-12-22 00:15:18 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-12-22 18:08:47 -0500
commitcaf2620f18affec2846b56de4f6bf6453296537a (patch)
treec05649e2e57bc2c66c3ef017d6d43a89c77d17d8 /src
parent40f9b1dd2cd843a001d7df90647706704f240eb5 (diff)
downloadrneovim-caf2620f18affec2846b56de4f6bf6453296537a.tar.gz
rneovim-caf2620f18affec2846b56de4f6bf6453296537a.tar.bz2
rneovim-caf2620f18affec2846b56de4f6bf6453296537a.zip
vim-patch:8.2.0769: VimLeavePre not triggered when Vim is terminated
Problem: VimLeavePre not triggered when Vim is terminated. Solution: Unblock autocommands. https://github.com/vim/vim/commit/129d6bf6b3d120b0a4c69e18b5e8602a84e352bf
Diffstat (limited to 'src')
-rw-r--r--src/nvim/main.c13
-rw-r--r--src/nvim/testdir/test_signals.vim13
2 files changed, 24 insertions, 2 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c
index ed055e76ba..41ae78e996 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -653,7 +653,18 @@ void getout(int exitval)
}
}
}
- apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf);
+
+ int unblock = 0;
+ // 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();
+ }
}
if (p_shada && *p_shada != NUL) {
diff --git a/src/nvim/testdir/test_signals.vim b/src/nvim/testdir/test_signals.vim
index fdcb37a6d9..fab42cb7c6 100644
--- a/src/nvim/testdir/test_signals.vim
+++ b/src/nvim/testdir/test_signals.vim
@@ -98,8 +98,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")
@@ -116,8 +121,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