@@ -175,15 +175,12 @@ local move_tbl = {
175
175
function View :setup_tabpage (tabpage , callsite )
176
176
local winnr = vim .api .nvim_get_current_win ()
177
177
178
- local msg = nil
179
178
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" )
187
184
end
188
185
189
186
globals .TABPAGES [tabpage ] = vim .tbl_extend (" force" , globals .TABPAGES [tabpage ] or tabinitial , { winnr = winnr })
@@ -447,9 +444,21 @@ function View:reposition_window()
447
444
end
448
445
449
446
--- @private
450
- function View :set_current_win ()
447
+ function View :set_current_win (callsite )
451
448
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
453
462
end
454
463
455
464
--- Open the tree in the a window
@@ -462,7 +471,7 @@ function View:open_in_win(opts)
462
471
end
463
472
self :create_buffer (opts .hijack_current_buf and vim .api .nvim_get_current_buf ())
464
473
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 " )
466
475
self :set_window_options_and_buffer ()
467
476
if opts .resize then
468
477
self :reposition_window ()
@@ -600,7 +609,7 @@ function View:get_bufnr()
600
609
end
601
610
602
611
function 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 " )
604
613
local view_bufnr = self :get_bufnr ()
605
614
606
615
-- need to schedule to let the new buffer populate the window
@@ -615,6 +624,10 @@ function View:prevent_buffer_override()
615
624
if not bufname :match (" NvimTree" ) then
616
625
for i , tabpage in ipairs (globals .TABPAGES ) do
617
626
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
+
618
631
globals .TABPAGES [i ] = nil
619
632
break
620
633
end
0 commit comments