@@ -393,10 +393,10 @@ define(function (require, exports, module) {
393393 // determine the pane inside which the tab belongs
394394 const isSecondPane = $ ( this ) . closest ( "#phoenix-tab-bar-2" ) . length > 0 ;
395395 const paneId = isSecondPane ? "second-pane" : "first-pane" ;
396- const activeEditor = EditorManager . getActiveEditor ( ) ;
397396 const currentActivePane = MainViewManager . getActivePaneId ( ) ;
398397 const isPaneActive = ( paneId === currentActivePane ) ;
399- if ( isPaneActive && activeEditor && activeEditor . document . file . fullPath === filePath ) {
398+ const currentFile = MainViewManager . getCurrentlyViewedFile ( currentActivePane ) ;
399+ if ( isPaneActive && currentFile && currentFile . fullPath === filePath ) {
400400 return ;
401401 }
402402 CommandManager . execute ( Commands . FILE_OPEN , { fullPath : filePath , paneId : paneId } ) ;
@@ -423,25 +423,23 @@ define(function (require, exports, module) {
423423 }
424424
425425
426+ // debounce is used to prevent rapid consecutive calls to updateTabs,
427+ // which was causing integration tests to fail in Firefox. Without it,
428+ // the event fires too frequently when switching editors, leading to unexpected behavior
429+ const debounceUpdateTabs = _ . debounce ( updateTabs , 2 ) ;
430+
426431 /**
427432 * Registers the event handlers
428433 */
429- function registerHandlers ( ) {
434+ function _registerHandlers ( ) {
430435 // For pane layout changes, recreate the entire tab bar container
431- MainViewManager . off ( "paneCreate paneDestroy paneLayoutChange" , createTabBar ) ;
432436 MainViewManager . on ( "paneCreate paneDestroy paneLayoutChange" , createTabBar ) ;
433437
434438 // For active pane changes, update only the tabs
435- MainViewManager . off ( "activePaneChange" , updateTabs ) ;
436439 MainViewManager . on ( "activePaneChange" , updateTabs ) ;
437440
438441 // For editor changes, update only the tabs.
439- EditorManager . off ( "activeEditorChange" , updateTabs ) ;
440- // debounce is used to prevent rapid consecutive calls to updateTabs,
441- // which was causing integration tests to fail in Firefox. Without it,
442- // the event fires too frequently when switching editors, leading to unexpected behavior
443- const debounceUpdateTabs = _ . debounce ( updateTabs , 2 ) ;
444- EditorManager . on ( "activeEditorChange" , debounceUpdateTabs ) ;
442+ MainViewManager . on ( MainViewManager . EVENT_CURRENT_FILE_CHANGE , debounceUpdateTabs ) ;
445443
446444 // For working set changes, update only the tabs.
447445 const events = [
@@ -583,7 +581,7 @@ define(function (require, exports, module) {
583581 preferenceChanged ( ) ;
584582
585583 // this should be called at the last as everything should be setup before registering handlers
586- registerHandlers ( ) ;
584+ _registerHandlers ( ) ;
587585
588586 // handle when a single tab gets clicked
589587 handleTabClick ( ) ;
0 commit comments