vim-patch:8.2.2070: can't get the exit value in VimLeave(Pre) autocommands (#13981)

Problem:    Can't get the exit value in VimLeave or VimLeavePre autocommands.
Solution:   Add v:exiting like in Neovim. (Yegappan Lakshmanan, closes vim/vim#7395)
f0068c5154

Rearrange VimVarIndex enums and vimvars[] entries to sync with  Vim.

N/A patches for version.c:

vim-patch:8.2.2535: MS-Windows: cannot run all vim9 tests

Problem:    MS-Windows: cannot run all vim9 tests.
Solution:   Make test_vim9 target work.
723ef5db98
This commit is contained in:
Jan Edmund Lazo 2021-02-20 23:45:14 -05:00 committed by GitHub
parent 1caf58578c
commit 595f6e4d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 15 deletions

View File

@ -1541,7 +1541,10 @@ v:dying Normally zero. When a deadly signal is caught it's set to
VimLeave autocommands will not be executed.
*v:exiting* *exiting-variable*
v:exiting Exit code, or |v:null| if not exiting. |VimLeave|
v:exiting Exit code, or |v:null| before invoking the |VimLeavePre|
and |VimLeave| autocmds. See |:q|, |:x| and |:cquit|.
Example: >
:au VimLeave * echo "Exit value is " .. v:exiting
*v:echospace* *echospace-variable*
v:echospace Number of screen cells that can be used for an `:echo` message

View File

@ -176,7 +176,6 @@ static struct vimvar {
VV(VV_DYING, "dying", VAR_NUMBER, VV_RO),
VV(VV_EXCEPTION, "exception", VAR_STRING, VV_RO),
VV(VV_THROWPOINT, "throwpoint", VAR_STRING, VV_RO),
VV(VV_STDERR, "stderr", VAR_NUMBER, VV_RO),
VV(VV_REG, "register", VAR_STRING, VV_RO),
VV(VV_CMDBANG, "cmdbang", VAR_NUMBER, VV_RO),
VV(VV_INSERTMODE, "insertmode", VAR_STRING, VV_RO),
@ -211,13 +210,9 @@ static struct vimvar {
VV(VV_OPTION_OLD, "option_old", VAR_STRING, VV_RO),
VV(VV_OPTION_TYPE, "option_type", VAR_STRING, VV_RO),
VV(VV_ERRORS, "errors", VAR_LIST, 0),
VV(VV_MSGPACK_TYPES, "msgpack_types", VAR_DICT, VV_RO),
VV(VV_EVENT, "event", VAR_DICT, VV_RO),
VV(VV_FALSE, "false", VAR_BOOL, VV_RO),
VV(VV_TRUE, "true", VAR_BOOL, VV_RO),
VV(VV_NULL, "null", VAR_SPECIAL, VV_RO),
VV(VV__NULL_LIST, "_null_list", VAR_LIST, VV_RO),
VV(VV__NULL_DICT, "_null_dict", VAR_DICT, VV_RO),
VV(VV_VIM_DID_ENTER, "vim_did_enter", VAR_NUMBER, VV_RO),
VV(VV_TESTING, "testing", VAR_NUMBER, 0),
VV(VV_TYPE_NUMBER, "t_number", VAR_NUMBER, VV_RO),
@ -227,10 +222,16 @@ static struct vimvar {
VV(VV_TYPE_DICT, "t_dict", VAR_NUMBER, VV_RO),
VV(VV_TYPE_FLOAT, "t_float", VAR_NUMBER, VV_RO),
VV(VV_TYPE_BOOL, "t_bool", VAR_NUMBER, VV_RO),
VV(VV_EVENT, "event", VAR_DICT, VV_RO),
VV(VV_ECHOSPACE, "echospace", VAR_NUMBER, VV_RO),
VV(VV_EXITING, "exiting", VAR_NUMBER, VV_RO),
VV(VV_LUA, "lua", VAR_PARTIAL, VV_RO),
VV(VV_ARGV, "argv", VAR_LIST, VV_RO),
VV(VV_EXITING, "exiting", VAR_NUMBER, VV_RO),
// Neovim
VV(VV_STDERR, "stderr", VAR_NUMBER, VV_RO),
VV(VV_MSGPACK_TYPES, "msgpack_types", VAR_DICT, VV_RO),
VV(VV__NULL_LIST, "_null_list", VAR_LIST, VV_RO),
VV(VV__NULL_DICT, "_null_dict", VAR_DICT, VV_RO),
VV(VV_LUA, "lua", VAR_PARTIAL, VV_RO),
};
#undef VV

View File

@ -105,7 +105,6 @@ typedef enum {
VV_DYING,
VV_EXCEPTION,
VV_THROWPOINT,
VV_STDERR,
VV_REG,
VV_CMDBANG,
VV_INSERTMODE,
@ -140,13 +139,9 @@ typedef enum {
VV_OPTION_OLD,
VV_OPTION_TYPE,
VV_ERRORS,
VV_MSGPACK_TYPES,
VV_EVENT,
VV_FALSE,
VV_TRUE,
VV_NULL,
VV__NULL_LIST, // List with NULL value. For test purposes only.
VV__NULL_DICT, // Dictionary with NULL value. For test purposes only.
VV_VIM_DID_ENTER,
VV_TESTING,
VV_TYPE_NUMBER,
@ -156,10 +151,16 @@ typedef enum {
VV_TYPE_DICT,
VV_TYPE_FLOAT,
VV_TYPE_BOOL,
VV_EVENT,
VV_ECHOSPACE,
VV_EXITING,
VV_LUA,
VV_ARGV,
VV_EXITING,
// Neovim
VV_STDERR,
VV_MSGPACK_TYPES,
VV__NULL_LIST, // List with NULL value. For test purposes only.
VV__NULL_DICT, // Dictionary with NULL value. For test purposes only.
VV_LUA,
} VimVarIndex;
/// All recognized msgpack types

View File

@ -81,3 +81,32 @@ func Test_exiting()
endif
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 = null', 'ep = 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