fix: close the last window

This commit is contained in:
MengQ
2024-09-07 22:55:41 +08:00
parent e2fc8d8e10
commit c727d3a0ab

View File

@@ -76,10 +76,16 @@ end
---Close view window and remove winnr/bufnr fields ---Close view window and remove winnr/bufnr fields
function View:close() function View:close()
if self.win then if self.win then
local windows = vim.api.nvim_list_wins()
local win_count = #windows
if win_count == 1 then
vim.api.nvim_command('q')
else
vim.api.nvim_win_close(self.win, true) vim.api.nvim_win_close(self.win, true)
self.win = nil self.win = nil
self.buf = nil self.buf = nil
end end
end
end end
---Return whether view has valid buf and win numbers ---Return whether view has valid buf and win numbers