From ec530e73beec547e04efb11a4f17c912d750c626 Mon Sep 17 00:00:00 2001 From: kiyan Date: Mon, 18 Jul 2022 13:29:05 +0200 Subject: [PATCH] fix(wipe): wipe all nvim-tree rogue buffers also prevent find_file if bufnr is not valid fixes #1438 --- lua/nvim-tree.lua | 3 +++ lua/nvim-tree/view.lua | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/nvim-tree.lua b/lua/nvim-tree.lua index c2f62aa2..5758e9d2 100644 --- a/lua/nvim-tree.lua +++ b/lua/nvim-tree.lua @@ -148,6 +148,9 @@ function M.find_file(with_open, bufnr, bang) end bufnr = bufnr or api.nvim_get_current_buf() + if not api.nvim_buf_is_valid(bufnr) then + return + end local bufname = api.nvim_buf_get_name(bufnr) local filepath = utils.canonical_path(vim.fn.fnamemodify(bufname, ":p")) if not is_file_readable(filepath) then diff --git a/lua/nvim-tree/view.lua b/lua/nvim-tree/view.lua index 45cf92ea..6353dbcd 100644 --- a/lua/nvim-tree/view.lua +++ b/lua/nvim-tree/view.lua @@ -76,7 +76,7 @@ end local function wipe_rogue_buffer() for _, bufnr in ipairs(a.nvim_list_bufs()) do if not matches_bufnr(bufnr) and a.nvim_buf_get_name(bufnr):match "NvimTree" ~= nil then - return pcall(a.nvim_buf_delete, bufnr, { force = true }) + pcall(a.nvim_buf_delete, bufnr, { force = true }) end end end