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,9 +76,15 @@ 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
vim.api.nvim_win_close(self.win, true) local windows = vim.api.nvim_list_wins()
self.win = nil local win_count = #windows
self.buf = nil if win_count == 1 then
vim.api.nvim_command('q')
else
vim.api.nvim_win_close(self.win, true)
self.win = nil
self.buf = nil
end
end end
end end