From f938bcb3aeb52790312f8ee1d56a013d417824bc Mon Sep 17 00:00:00 2001 From: kiyan Date: Tue, 8 Feb 2022 22:04:13 +0100 Subject: [PATCH] fix: cleanup all dirs when hijacking window --- lua/nvim-tree.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index 251b3a8d..7bb3f301 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -76,7 +76,14 @@ function M.hijack_current_window() if not View.bufnr then View.bufnr = api.nvim_get_current_buf() else - api.nvim_buf_delete(api.nvim_get_current_buf(), { force = true }) + local bufs = api.nvim_list_bufs() + for _, buf in ipairs(bufs) do + local bufname = api.nvim_buf_get_name(buf) + local stat = luv.fs_stat(bufname) + if stat and stat.type == "directory" then + api.nvim_buf_delete(buf, { force = true }) + end + end end local current_tab = api.nvim_get_current_tabpage() if not View.tabpages then