fix(wipe): wipe all nvim-tree rogue buffers

also prevent find_file if bufnr is not valid
fixes #1438
This commit is contained in:
kiyan
2022-07-18 13:29:05 +02:00
parent 16753d5e25
commit ec530e73be
2 changed files with 4 additions and 1 deletions

View File

@@ -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

View File

@@ -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