We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8ed0e5d commit 18de5bbCopy full SHA for 18de5bb
lua/snacks/win.lua
@@ -518,7 +518,14 @@ function M:close(opts)
518
519
local close = function()
520
if win and vim.api.nvim_win_is_valid(win) then
521
- vim.api.nvim_win_close(win, true)
+ local ok, err = pcall(vim.api.nvim_win_close, win, true)
522
+ if not ok and (err and err:find("E444")) then
523
+ -- last window, so creat a split and close it again
524
+ vim.cmd("silent! vsplit")
525
+ pcall(vim.api.nvim_win_close, win, true)
526
+ elseif not ok then
527
+ error(err)
528
+ end
529
end
530
if buf and vim.api.nvim_buf_is_valid(buf) then
531
vim.api.nvim_buf_delete(buf, { force = true })
0 commit comments