@@ -175,15 +175,12 @@ local move_tbl = {
175175function View :setup_tabpage (tabpage , callsite )
176176 local winnr = vim .api .nvim_get_current_win ()
177177
178- local msg = nil
179178 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 )
179+ log .line (" dev" , " View:setup_tabpage(%3s, %-20.20s) w%d %s" ,
180+ tabpage ,
181+ callsite ,
182+ winnr ,
183+ globals .TABPAGES [tabpage ] and vim .inspect (globals .TABPAGES [tabpage ], { newline = " " }) or " tabinitial" )
187184 end
188185
189186 globals .TABPAGES [tabpage ] = vim .tbl_extend (" force" , globals .TABPAGES [tabpage ] or tabinitial , { winnr = winnr })
@@ -447,9 +444,21 @@ function View:reposition_window()
447444end
448445
449446--- @private
450- function View :set_current_win ()
447+ function View :set_current_win (callsite )
451448 local current_tab = vim .api .nvim_get_current_tabpage ()
452- globals .TABPAGES [current_tab ].winnr = vim .api .nvim_get_current_win ()
449+ local current_win = vim .api .nvim_get_current_win ()
450+
451+ if self .explorer .opts .experimental .multi_instance_debug then
452+ log .line (" dev" , " View:set_current_win(%-20.20s) t%d w%3d->w%3d %s" ,
453+ callsite ,
454+ current_tab ,
455+ globals .TABPAGES [current_tab ].winnr ,
456+ current_win ,
457+ (globals .TABPAGES [current_tab ].winnr == current_win ) and " " or " UPDATED"
458+ )
459+ end
460+
461+ globals .TABPAGES [current_tab ].winnr = current_win
453462end
454463
455464--- Open the tree in the a window
@@ -462,7 +471,7 @@ function View:open_in_win(opts)
462471 end
463472 self :create_buffer (opts .hijack_current_buf and vim .api .nvim_get_current_buf ())
464473 self :setup_tabpage (vim .api .nvim_get_current_tabpage (), " View:open_in_win" )
465- self :set_current_win ()
474+ self :set_current_win (" View:open_in_win " )
466475 self :set_window_options_and_buffer ()
467476 if opts .resize then
468477 self :reposition_window ()
@@ -600,7 +609,7 @@ function View:get_bufnr()
600609end
601610
602611function View :prevent_buffer_override ()
603- local view_winnr = self :get_winnr (nil , " View:get_bufnr " )
612+ local view_winnr = self :get_winnr (nil , " View:prevent_buffer_override " )
604613 local view_bufnr = self :get_bufnr ()
605614
606615 -- need to schedule to let the new buffer populate the window
@@ -615,6 +624,10 @@ function View:prevent_buffer_override()
615624 if not bufname :match (" NvimTree" ) then
616625 for i , tabpage in ipairs (globals .TABPAGES ) do
617626 if tabpage .winnr == view_winnr then
627+ if self .explorer .opts .experimental .multi_instance_debug then
628+ log .line (" dev" , " View:prevent_buffer_override() t%d w%d clearing" , i , view_winnr )
629+ end
630+
618631 globals .TABPAGES [i ] = nil
619632 break
620633 end
0 commit comments