commit 8133760c989e3da797fccb802efe0ee431219ff3
parent b4e602dde544d2b18bc7813415565fbe6ab1041b
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue, 20 Jan 2026 06:32:32 +0800
test: add tests for #14379
Diffstat:
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua
@@ -118,3 +118,31 @@ describe(':cquit', function()
)
end)
end)
+
+describe('no crash after :quit non-last window during exit', function()
+ before_each(function()
+ n.clear()
+ end)
+
+ it('in vim.schedule() callback and when piping to stdin #14379', function()
+ n.fn.system({
+ n.nvim_prog,
+ '-es',
+ '--cmd',
+ "lua vim.schedule(function() vim.cmd('vsplit | quit') end)",
+ '+quit',
+ }, '')
+ eq(0, n.api.nvim_get_vvar('shell_error'))
+ end)
+
+ it('in vim.defer_fn() callback and when piping to stdin #14379', function()
+ n.fn.system({
+ n.nvim_prog,
+ '-es',
+ '--cmd',
+ "lua vim.defer_fn(function() vim.cmd('vsplit | quit') end, 0)",
+ '+quit',
+ }, '')
+ eq(0, n.api.nvim_get_vvar('shell_error'))
+ end)
+end)
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
@@ -2468,6 +2468,22 @@ describe('TUI', function()
screen:expect({ any = vim.pesc('[Process exited 1]') })
end)
+ it('exits properly when :quit non-last window in event handler #14379', function()
+ local code = [[
+ vim.defer_fn(function()
+ vim.cmd('vsplit | quit')
+ end, 0)
+ vim.cmd('quit')
+ ]]
+ child_session:notify('nvim_exec_lua', code, {})
+ screen:expect([[
+ |
+ [Process exited 0]^ |
+ |*4
+ {5:-- TERMINAL --} |
+ ]])
+ end)
+
it('no stack-use-after-scope with cursor color #22432', function()
screen:set_option('rgb', true)
command('set termguicolors')