+58
-0
lines changedFilter options
+58
-0
lines changed Original file line number Diff line number Diff line change
@@ -1383,6 +1383,9 @@ v:dying Normally zero. When a deadly signal is caught it's set to
1383
1383
< Note: if another deadly signal is caught when v:dying is one,
1384
1384
VimLeave autocommands will not be executed.
1385
1385
1386
+
*v:exiting* *exiting-variable*
1387
+
v:exiting The exit value Nvim will use. Before exiting, it is |v:null|.
1388
+
1386
1389
*v:errmsg* *errmsg-variable*
1387
1390
v:errmsg Last given error message. It's allowed to set this variable.
1388
1391
Example: >
Original file line number Diff line number Diff line change
@@ -394,6 +394,7 @@ static struct vimvar {
394
394
VV(VV_TYPE_DICT, "t_dict", VAR_NUMBER, VV_RO),
395
395
VV(VV_TYPE_FLOAT, "t_float", VAR_NUMBER, VV_RO),
396
396
VV(VV_TYPE_BOOL, "t_bool", VAR_NUMBER, VV_RO),
397
+
VV(VV_EXITING, "exiting", VAR_NUMBER, VV_RO),
397
398
};
398
399
#undef VV
399
400
@@ -581,6 +582,7 @@ void eval_init(void)
581
582
set_vim_var_special(VV_FALSE, kSpecialVarFalse);
582
583
set_vim_var_special(VV_TRUE, kSpecialVarTrue);
583
584
set_vim_var_special(VV_NULL, kSpecialVarNull);
585
+
set_vim_var_special(VV_EXITING, kSpecialVarNull);
584
586
585
587
set_reg_var(0); // default for v:register is not 0 but '"'
586
588
}
@@ -17763,6 +17765,8 @@ void set_vcount(long count, long count1, int set_prevcount)
17763
17765
/// @param[in] val Value to set to.
17764
17766
void set_vim_var_nr(const VimVarIndex idx, const varnumber_T val)
17765
17767
{
17768
+
clear_tv(&vimvars[idx].vv_tv);
17769
+
vimvars[idx].vv_type = VAR_NUMBER;
17766
17770
vimvars[idx].vv_nr = val;
17767
17771
}
17768
17772
@@ -17772,6 +17776,8 @@ void set_vim_var_nr(const VimVarIndex idx, const varnumber_T val)
17772
17776
/// @param[in] val Value to set to.
17773
17777
void set_vim_var_special(const VimVarIndex idx, const SpecialVarValue val)
17774
17778
{
17779
+
clear_tv(&vimvars[idx].vv_tv);
17780
+
vimvars[idx].vv_type = VAR_SPECIAL;
17775
17781
vimvars[idx].vv_special = val;
17776
17782
}
17777
17783
Original file line number Diff line number Diff line change
@@ -134,6 +134,7 @@ typedef enum {
134
134
VV_TYPE_DICT,
135
135
VV_TYPE_FLOAT,
136
136
VV_TYPE_BOOL,
137
+
VV_EXITING,
137
138
} VimVarIndex;
138
139
139
140
/// All recognized msgpack types
Original file line number Diff line number Diff line change
@@ -557,6 +557,8 @@ void getout(int exitval)
557
557
if (exmode_active)
558
558
exitval += ex_exitval;
559
559
560
+
set_vim_var_nr(VV_EXITING, exitval);
561
+
560
562
/* Position the cursor on the last screen line, below all the text */
561
563
ui_cursor_goto((int)Rows - 1, 0);
562
564
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
1
+
local helpers = require('test.functional.helpers')(after_each)
2
+
3
+
local command = helpers.command
4
+
local eval = helpers.eval
5
+
local eq, neq = helpers.eq, helpers.neq
6
+
local run = helpers.run
7
+
8
+
describe('v:exiting', function()
9
+
local cid
10
+
11
+
before_each(function()
12
+
helpers.clear()
13
+
cid = helpers.nvim('get_api_info')[1]
14
+
end)
15
+
16
+
it('defaults to v:null', function()
17
+
eq(1, eval('v:exiting is v:null'))
18
+
end)
19
+
20
+
it('is 0 on normal exit', function()
21
+
local function on_setup()
22
+
command('autocmd VimLeavePre * call rpcrequest('..cid..', "")')
23
+
command('autocmd VimLeave * call rpcrequest('..cid..', "")')
24
+
command('quit')
25
+
end
26
+
local function on_request()
27
+
eq(0, eval('v:exiting'))
28
+
return ''
29
+
end
30
+
run(on_request, nil, on_setup)
31
+
end)
32
+
33
+
it('is non-zero after :cquit', function()
34
+
local function on_setup()
35
+
command('autocmd VimLeavePre * call rpcrequest('..cid..', "")')
36
+
command('autocmd VimLeave * call rpcrequest('..cid..', "")')
37
+
command('cquit')
38
+
end
39
+
local function on_request()
40
+
neq(0, eval('v:exiting'))
41
+
return ''
42
+
end
43
+
run(on_request, nil, on_setup)
44
+
end)
45
+
46
+
end)
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4