Skip to content

Commit d1df6d4

Browse files
committed
refactor(#2826): explorer init logging
1 parent d822fdd commit d1df6d4

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

lua/nvim-tree/actions/root/change-dir.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ M.force_dirchange = add_profiling_to(function(foldername, should_open_view)
8585
if should_change_dir() then
8686
cd(M.options.global, foldername)
8787
end
88-
core.init(foldername)
88+
core.init(foldername, "change-dir")
8989
end
9090

9191
if should_open_view then

lua/nvim-tree/core.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ local TreeExplorer = nil
99
local first_init_done = false
1010

1111
---@param foldername string
12-
function M.init(foldername)
12+
---@param callsite string
13+
function M.init(foldername, callsite)
1314
local profile = log.profile_start("core init %s", foldername)
1415

16+
log.line("dev", "core.init(%s, %s)", foldername, callsite)
17+
1518
if TreeExplorer then
1619
TreeExplorer:destroy()
1720
end

lua/nvim-tree/explorer/view.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ local DEFAULT_PADDING = 1
3131
---@field private width (fun():integer)|integer|string
3232
---@field private max_width integer
3333
---@field private padding integer
34-
---@field private bufnr_by_tab table<integer, integer> for diagnostics during multi instance
34+
---@field private bufnr_by_tab table<integer, integer> stored per tab until multi-instance is complete
3535
local View = Class:extend()
3636

3737
---@class View
@@ -617,15 +617,14 @@ end
617617
---@param callsite string
618618
---@return integer? winid
619619
function View:winid(tabpage, callsite)
620-
local winid = nil
621620
local bufnr = self.bufnr_by_tab[tabpage]
622621

623622
local msg = string.format("View:winid(%3s, %-20.20s)", tabpage, callsite)
624623

625624
if bufnr then
626625
for _, w in pairs(vim.api.nvim_tabpage_list_wins(tabpage or 0)) do
627626
if vim.api.nvim_win_get_buf(w) == bufnr then
628-
log.line("dev", "%s b%d : w%s", msg, bufnr, winid)
627+
log.line("dev", "%s b%d : w%s", msg, bufnr, w)
629628
return w
630629
end
631630
end

lua/nvim-tree/lib.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ function M.open(opts)
102102
M.set_target_win()
103103
if not core.get_explorer() or opts.path then
104104
if opts.path then
105-
core.init(opts.path)
105+
core.init(opts.path, "lib.open - opts.path")
106106
else
107107
local cwd, err = vim.loop.cwd()
108108
if not cwd then
109109
notify.error(string.format("current working directory unavailable: %s", err))
110110
return
111111
end
112-
core.init(cwd)
112+
core.init(cwd, "lib.open - cwd")
113113
end
114114
end
115115

0 commit comments

Comments
 (0)