commit d42fa1753adc18c4b22577724a804d556a16d736
parent 4d46d040c3215373f8cf64378d03d004e095d646
Author: zeertzjq <zeertzjq@outlook.com>
Date: Mon, 5 Jan 2026 13:58:47 +0800
test(terminal): fix incorrect TermClose test
The test may wipe the wrong buffer if :bdelete switches to another one.
Also remove the builtin TermClose autocommand. It doesn't affect the
tests for now, but still it's better to avoid its interference.
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/test/functional/autocmd/termxx_spec.lua b/test/functional/autocmd/termxx_spec.lua
@@ -20,13 +20,15 @@ describe('autocmd TermClose', function()
clear()
api.nvim_set_option_value('shell', testprg('shell-test'), {})
command('set shellcmdflag=EXE shellredir= shellpipe= shellquote= shellxquote=')
+ command('autocmd! nvim.terminal TermClose')
end)
local function test_termclose_delete_own_buf()
-- The terminal process needs to keep running so that TermClose isn't triggered immediately.
api.nvim_set_option_value('shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
- command('autocmd TermClose * bdelete!')
command('terminal')
+ local termbuf = api.nvim_get_current_buf()
+ command(('autocmd TermClose * bdelete! %d'):format(termbuf))
matches(
'^TermClose Autocommands for "%*": Vim%(bdelete%):E937: Attempt to delete a buffer that is in use: term://',
pcall_err(command, 'bdelete!')
@@ -34,8 +36,7 @@ describe('autocmd TermClose', function()
assert_alive()
end
- -- TODO: fixed after merging patches for `can_unload_buffer`?
- pending('TermClose deleting its own buffer, altbuf = buffer 1 #10386', function()
+ it('TermClose deleting its own buffer, altbuf = buffer 1 #10386', function()
test_termclose_delete_own_buf()
end)