fix(wipe): wipe all nvim-tree rogue buffers
also prevent find_file if bufnr is not valid fixes #1438
This commit is contained in:
@@ -148,6 +148,9 @@ function M.find_file(with_open, bufnr, bang)
|
|||||||
end
|
end
|
||||||
|
|
||||||
bufnr = bufnr or api.nvim_get_current_buf()
|
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 bufname = api.nvim_buf_get_name(bufnr)
|
||||||
local filepath = utils.canonical_path(vim.fn.fnamemodify(bufname, ":p"))
|
local filepath = utils.canonical_path(vim.fn.fnamemodify(bufname, ":p"))
|
||||||
if not is_file_readable(filepath) then
|
if not is_file_readable(filepath) then
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ end
|
|||||||
local function wipe_rogue_buffer()
|
local function wipe_rogue_buffer()
|
||||||
for _, bufnr in ipairs(a.nvim_list_bufs()) do
|
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
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user