mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
fix(win): properly handle closing the last window. Fixes #793
This commit is contained in:
parent
8ed0e5d191
commit
18de5bb238
1 changed files with 8 additions and 1 deletions
|
@ -518,7 +518,14 @@ function M:close(opts)
|
|||
|
||||
local close = function()
|
||||
if win and vim.api.nvim_win_is_valid(win) then
|
||||
vim.api.nvim_win_close(win, true)
|
||||
local ok, err = pcall(vim.api.nvim_win_close, win, true)
|
||||
if not ok and (err and err:find("E444")) then
|
||||
-- last window, so creat a split and close it again
|
||||
vim.cmd("silent! vsplit")
|
||||
pcall(vim.api.nvim_win_close, win, true)
|
||||
elseif not ok then
|
||||
error(err)
|
||||
end
|
||||
end
|
||||
if buf and vim.api.nvim_buf_is_valid(buf) then
|
||||
vim.api.nvim_buf_delete(buf, { force = true })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue