From c727d3a0ab64bc705c67bdc466d57ea67fec952c Mon Sep 17 00:00:00 2001 From: MengQ <1844325293@qq.com> Date: Sat, 7 Sep 2024 22:55:41 +0800 Subject: [PATCH] fix: close the last window --- lua/outline/view.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lua/outline/view.lua b/lua/outline/view.lua index 2848d83..755d47c 100644 --- a/lua/outline/view.lua +++ b/lua/outline/view.lua @@ -76,9 +76,15 @@ end ---Close view window and remove winnr/bufnr fields function View:close() if self.win then - vim.api.nvim_win_close(self.win, true) - self.win = nil - self.buf = nil + 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) + self.win = nil + self.buf = nil + end end end