Merge pull request #91 from MengQ0627/quit-last-window

fix: close the last window
This commit is contained in:
~hedy
2024-09-08 09:11:14 +08:00
committed by GitHub

View File

@@ -76,11 +76,17 @@ 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
function View:is_open() function View:is_open()