mirror of
https://github.com/vim/vim.git
synced 2025-10-28 09:27:14 -04:00
patch 8.2.2070: can't get the exit value in VimLeave(Pre) autocommands
Problem: Can't get the exit value in VimLeave or VimLeavePre autocommands. Solution: Add v:exiting like in Neovim. (Yegappan Lakshmanan, closes #7395)
This commit is contained in:
@@ -82,4 +82,31 @@ func Test_exiting()
|
||||
call delete('Xtestout')
|
||||
endfunc
|
||||
|
||||
" Test for getting the Vim exit code from v:exiting
|
||||
func Test_exit_code()
|
||||
call assert_equal(v:null, v:exiting)
|
||||
|
||||
let before =<< trim [CODE]
|
||||
au QuitPre * call writefile(['qp = ' .. v:exiting], 'Xtestout', 'a')
|
||||
au ExitPre * call writefile(['ep = ' .. v:exiting], 'Xtestout', 'a')
|
||||
au VimLeavePre * call writefile(['lp = ' .. v:exiting], 'Xtestout', 'a')
|
||||
au VimLeave * call writefile(['l = ' .. v:exiting], 'Xtestout', 'a')
|
||||
[CODE]
|
||||
|
||||
if RunVim(before, ['quit'], '')
|
||||
call assert_equal(['qp = v:null', 'ep = v:null', 'lp = 0', 'l = 0'], readfile('Xtestout'))
|
||||
endif
|
||||
call delete('Xtestout')
|
||||
|
||||
if RunVim(before, ['cquit'], '')
|
||||
call assert_equal(['lp = 1', 'l = 1'], readfile('Xtestout'))
|
||||
endif
|
||||
call delete('Xtestout')
|
||||
|
||||
if RunVim(before, ['cquit 4'], '')
|
||||
call assert_equal(['lp = 4', 'l = 4'], readfile('Xtestout'))
|
||||
endif
|
||||
call delete('Xtestout')
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
Reference in New Issue
Block a user