@@ -507,20 +507,37 @@ define(function (require, exports, module) {
507507 event . stopPropagation ( ) ;
508508
509509 CommandManager . execute ( Commands . FILE_CLOSE , { file : fileObj , paneId : paneId } ) ; // close the file
510- } else { // open the clicked tab
511- const currentActivePane = MainViewManager . getActivePaneId ( ) ;
512- const isPaneActive = paneId === currentActivePane ;
513- const currentFile = MainViewManager . getCurrentlyViewedFile ( currentActivePane ) ;
514-
515- // if the clicked tab is a placeholder tab, we add it to the working set
516- if ( $ ( this ) . hasClass ( "placeholder" ) ) {
517- MainViewManager . addToWorkingSet ( paneId , fileObj ) ;
518- }
510+ }
511+ } ) ;
519512
520- // clicked tab is already active, don't do anything
521- if ( isPaneActive && currentFile && currentFile . fullPath === filePath ) { return ; }
522- CommandManager . execute ( Commands . FILE_OPEN , { fullPath : filePath , paneId : paneId } ) ;
513+ // open tab on mousedown event
514+ $ ( document ) . on ( "mousedown" , ".phoenix-tab-bar .tab" , function ( event ) {
515+ if ( $ ( event . target ) . hasClass ( "fa-times" ) || $ ( event . target ) . closest ( ".tab-close" ) . length ) {
516+ return ;
523517 }
518+
519+ // Get the file path from the data-path attribute of the parent tab
520+ const filePath = $ ( this ) . attr ( "data-path" ) ;
521+ if ( ! filePath ) { return ; }
522+
523+ // determine the pane inside which the tab belongs
524+ const isSecondPane = $ ( this ) . closest ( "#phoenix-tab-bar-2" ) . length > 0 ;
525+ const paneId = isSecondPane ? "second-pane" : "first-pane" ;
526+
527+ // get the file object
528+ const fileObj = FileSystem . getFileForPath ( filePath ) ;
529+ const currentActivePane = MainViewManager . getActivePaneId ( ) ;
530+ const isPaneActive = paneId === currentActivePane ;
531+ const currentFile = MainViewManager . getCurrentlyViewedFile ( currentActivePane ) ;
532+
533+ // if the clicked tab is a placeholder tab, we add it to the working set
534+ if ( $ ( this ) . hasClass ( "placeholder" ) ) {
535+ MainViewManager . addToWorkingSet ( paneId , fileObj ) ;
536+ }
537+
538+ // clicked tab is already active, don't do anything
539+ if ( isPaneActive && currentFile && currentFile . fullPath === filePath ) { return ; }
540+ CommandManager . execute ( Commands . FILE_OPEN , { fullPath : filePath , paneId : paneId } ) ;
524541 } ) ;
525542
526543 // Add the contextmenu (right-click) handler
0 commit comments