vim-patch:8.2.0769: VimLeavePre not triggered when Vim is terminated

Problem:    VimLeavePre not triggered when Vim is terminated.
Solution:   Unblock autocommands.
129d6bf6b3
This commit is contained in:
Jan Edmund Lazo 2020-12-22 00:15:18 -05:00
parent 40f9b1dd2c
commit caf2620f18
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 24 additions and 2 deletions

View File

@ -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) {

View File

@ -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