From 9ba985c2501bd7ad14c19f9e3dcbc9b5c38b2b87 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 20 Jan 2026 06:32:32 +0800 Subject: [PATCH] test: add tests for #14379 --- test/functional/core/exit_spec.lua | 28 +++++++++++++++++++++++++++ test/functional/terminal/tui_spec.lua | 16 +++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/test/functional/core/exit_spec.lua b/test/functional/core/exit_spec.lua index 1314916168..682649603e 100644 --- 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 index 618f779b70..5555d2bcb8 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -2169,6 +2169,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 + {3:-- TERMINAL --} | + ]]) + end) + it('no stack-use-after-scope with cursor color #22432', function() screen:set_option('rgb', true) command('set termguicolors')