test(terminal): status is -1 in TermClose if buffer is deleted (#37609)

This commit is contained in:
zeertzjq
2026-01-29 16:29:49 +08:00
committed by GitHub
parent 4e4e1b09d3
commit 484f455402
4 changed files with 12 additions and 5 deletions

View File

@@ -1077,7 +1077,8 @@ TermLeave After leaving |Terminal-mode|.
*TermClose*
TermClose When a |terminal| job ends.
Sets these |v:event| keys:
status
status job exit status, or -1 if the
terminal buffer is deleted
*TermRequest*
TermRequest When a |:terminal| child process emits an OSC,
DCS, or APC sequence. Sets |v:termrequest|. The

View File

@@ -3632,7 +3632,7 @@ void f_jobstart(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
// Terminal URI: "term://$CWD//$PID:$CMD"
snprintf(NameBuff, sizeof(NameBuff), "term://%s//%d:%s", IObuff, pid, cmd);
// Buffer has no terminal associated yet; unset 'swapfile' to ensure no swapfile is created.
// Unset 'swapfile' to ensure no swapfile is created.
buf->b_p_swf = false;
setfname(buf, NameBuff, NULL, true);

View File

@@ -184,6 +184,13 @@ describe('autocmd TermClose', function()
retry(nil, nil, function()
eq(42, eval('g:status'))
end)
command('set shellcmdflag= | terminal INTERACT')
retry(nil, nil, function()
matches('^interact %$ ?$', api.nvim_buf_get_lines(0, 0, 1, true)[1])
end)
command('bwipe!')
eq(-1, eval('g:status'))
end)
end)

View File

@@ -89,11 +89,10 @@ describe(':terminal buffer', function()
end)
it('does not create swap files', function()
local swapfile = api.nvim_exec('swapname', true):gsub('\n', '')
eq(nil, io.open(swapfile))
eq('No swap file', n.exec_capture('swapname'))
end)
it('does not create undofiles files', function()
it('does not create undo files', function()
local undofile = api.nvim_eval('undofile(bufname("%"))')
eq(nil, io.open(undofile))
end)