Skip to content

Commit 8385953

Browse files
committed
refactor(#2826): instrument View:setup_tabpage
1 parent cdc4395 commit 8385953

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lua/nvim-tree/explorer/view.lua

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,21 @@ local move_tbl = {
171171
-- setup_tabpage sets up the initial state of a tab
172172
---@private
173173
---@param tabpage integer
174-
function View:setup_tabpage(tabpage)
174+
---@param callsite string?
175+
function View:setup_tabpage(tabpage, callsite)
175176
local winnr = vim.api.nvim_get_current_win()
177+
178+
local msg = nil
179+
if self.explorer.opts.experimental.multi_instance_debug then
180+
msg = string.format( "View:setup_tabpage(%3s, %-20.20s) w%d", tabpage, callsite, winnr)
181+
if globals.TABPAGES[tabpage] then
182+
msg = string.format("%s %s", msg, vim.inspect(globals.TABPAGES[tabpage], { newline = "" }))
183+
else
184+
msg = string.format("%s tabinitial", msg)
185+
end
186+
log.line("dev", "%s", msg)
187+
end
188+
176189
globals.TABPAGES[tabpage] = vim.tbl_extend("force", globals.TABPAGES[tabpage] or tabinitial, { winnr = winnr })
177190
end
178191

@@ -221,7 +234,7 @@ function View:open_window()
221234
vim.api.nvim_command("vsp")
222235
self:reposition_window()
223236
end
224-
self:setup_tabpage(vim.api.nvim_get_current_tabpage())
237+
self:setup_tabpage(vim.api.nvim_get_current_tabpage(), "View:open_window")
225238
self:set_window_options_and_buffer()
226239
end
227240

@@ -448,7 +461,7 @@ function View:open_in_win(opts)
448461
vim.api.nvim_set_current_win(opts.winid)
449462
end
450463
self:create_buffer(opts.hijack_current_buf and vim.api.nvim_get_current_buf())
451-
self:setup_tabpage(vim.api.nvim_get_current_tabpage())
464+
self:setup_tabpage(vim.api.nvim_get_current_tabpage(), "View:open_in_win")
452465
self:set_current_win()
453466
self:set_window_options_and_buffer()
454467
if opts.resize then

0 commit comments

Comments
 (0)