|
1 | 1 | local Iterator = require "nvim-tree.iterators.node-iterator"
|
2 | 2 | local notify = require "nvim-tree.notify"
|
| 3 | +local log = require "nvim-tree.log" |
3 | 4 |
|
4 | 5 | local M = {
|
5 | 6 | debouncers = {},
|
@@ -477,4 +478,51 @@ function M.is_nvim_tree_buf(bufnr)
|
477 | 478 | return false
|
478 | 479 | end
|
479 | 480 |
|
| 481 | +---Profile a call to vim.loop.fs_scandir |
| 482 | +---This should be removed following resolution of #1831 |
| 483 | +---@param path string |
| 484 | +---@return userdata|nil uv_fs_t |
| 485 | +---@return string|nil type |
| 486 | +---@return string|nil err (fail) |
| 487 | +---@return string|nil name (fail) |
| 488 | +function M.fs_scandir_profiled(path) |
| 489 | + local pn = string.format("fs_scandir %s", path) |
| 490 | + local ps = log.profile_start(pn) |
| 491 | + |
| 492 | + local handle, err, name = vim.loop.fs_scandir(path) |
| 493 | + |
| 494 | + if err or name then |
| 495 | + log.line("profile", " %s err '%s'", pn, vim.inspect(err)) |
| 496 | + log.line("profile", " %s name '%s'", pn, vim.inspect(name)) |
| 497 | + end |
| 498 | + |
| 499 | + log.profile_end(ps, pn) |
| 500 | + |
| 501 | + return handle, err, name |
| 502 | +end |
| 503 | + |
| 504 | +---Profile a call to vim.loop.fs_scandir_next |
| 505 | +---This should be removed following resolution of #1831 |
| 506 | +---@param handle userdata uv_fs_t |
| 507 | +---@param tag string arbitrary |
| 508 | +---@return string|nil name |
| 509 | +---@return string|nil type |
| 510 | +---@return string|nil err (fail) |
| 511 | +---@return string|nil name (fail) |
| 512 | +function M.fs_scandir_next_profiled(handle, tag) |
| 513 | + local pn = string.format("fs_scandir_next %s", tag) |
| 514 | + local ps = log.profile_start(pn) |
| 515 | + |
| 516 | + local n, t, err, name = vim.loop.fs_scandir_next(handle) |
| 517 | + |
| 518 | + if err or name then |
| 519 | + log.line("profile", " %s err '%s'", pn, vim.inspect(err)) |
| 520 | + log.line("profile", " %s name '%s'", pn, vim.inspect(name)) |
| 521 | + end |
| 522 | + |
| 523 | + log.profile_end(ps, pn) |
| 524 | + |
| 525 | + return n, t, err, name |
| 526 | +end |
| 527 | + |
480 | 528 | return M
|
0 commit comments