fix(#1831): improve fs_scandir error handling, add profiling
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
local Iterator = require "nvim-tree.iterators.node-iterator"
|
||||
local notify = require "nvim-tree.notify"
|
||||
local log = require "nvim-tree.log"
|
||||
|
||||
local M = {
|
||||
debouncers = {},
|
||||
@@ -477,4 +478,51 @@ function M.is_nvim_tree_buf(bufnr)
|
||||
return false
|
||||
end
|
||||
|
||||
---Profile a call to vim.loop.fs_scandir
|
||||
---This should be removed following resolution of #1831
|
||||
---@param path string
|
||||
---@return userdata|nil uv_fs_t
|
||||
---@return string|nil type
|
||||
---@return string|nil err (fail)
|
||||
---@return string|nil name (fail)
|
||||
function M.fs_scandir_profiled(path)
|
||||
local pn = string.format("fs_scandir %s", path)
|
||||
local ps = log.profile_start(pn)
|
||||
|
||||
local handle, err, name = vim.loop.fs_scandir(path)
|
||||
|
||||
if err or name then
|
||||
log.line("profile", " %s err '%s'", pn, vim.inspect(err))
|
||||
log.line("profile", " %s name '%s'", pn, vim.inspect(name))
|
||||
end
|
||||
|
||||
log.profile_end(ps, pn)
|
||||
|
||||
return handle, err, name
|
||||
end
|
||||
|
||||
---Profile a call to vim.loop.fs_scandir_next
|
||||
---This should be removed following resolution of #1831
|
||||
---@param handle userdata uv_fs_t
|
||||
---@param tag string arbitrary
|
||||
---@return string|nil name
|
||||
---@return string|nil type
|
||||
---@return string|nil err (fail)
|
||||
---@return string|nil name (fail)
|
||||
function M.fs_scandir_next_profiled(handle, tag)
|
||||
local pn = string.format("fs_scandir_next %s", tag)
|
||||
local ps = log.profile_start(pn)
|
||||
|
||||
local n, t, err, name = vim.loop.fs_scandir_next(handle)
|
||||
|
||||
if err or name then
|
||||
log.line("profile", " %s err '%s'", pn, vim.inspect(err))
|
||||
log.line("profile", " %s name '%s'", pn, vim.inspect(name))
|
||||
end
|
||||
|
||||
log.profile_end(ps, pn)
|
||||
|
||||
return n, t, err, name
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user