@@ -92,17 +92,22 @@ define(function (require, exports, module) {
9292 * Note: this creates a tab (for a single file) not the tab bar
9393 *
9494 * @param {Object } entry - the working set entry
95+ * @param {String } paneId - the pane id 'first-pane' or 'second-pane'
9596 * @returns {$.Element } the tab element
9697 */
97- function createTab ( entry ) {
98- if ( ! $tabBar ) {
98+ function createTab ( entry , paneId ) {
99+ if ( ! $tabBar || ! paneId ) {
99100 return ;
100101 }
101102
102103 // set up all the necessary properties
103104 const activeEditor = EditorManager . getActiveEditor ( ) ;
104105 const activePath = activeEditor ? activeEditor . document . file . fullPath : null ;
105- const isActive = entry . path === activePath ; // if the file is the currently active file
106+
107+ const currentActivePane = MainViewManager . getActivePaneId ( ) ;
108+ // if the file is the currently active file
109+ // also verify that the tab belongs to the active pane
110+ const isActive = ( entry . path === activePath && paneId === currentActivePane ) ;
106111 const isDirty = Helper . _isFileModified ( FileSystem . getFileForPath ( entry . path ) ) ; // if the file is dirty
107112
108113 // Create the tab element with the structure we need
@@ -190,7 +195,7 @@ define(function (require, exports, module) {
190195
191196 // add each tab to the first pane's tab bar
192197 displayedEntries . forEach ( function ( entry ) {
193- $firstTabBar . append ( createTab ( entry ) ) ;
198+ $firstTabBar . append ( createTab ( entry , "first-pane" ) ) ;
194199 Overflow . toggleOverflowVisibility ( "first-pane" ) ;
195200 setTimeout ( function ( ) {
196201 Overflow . scrollToActiveTab ( $firstTabBar ) ;
@@ -210,7 +215,7 @@ define(function (require, exports, module) {
210215 }
211216
212217 displayedEntries2 . forEach ( function ( entry ) {
213- $secondTabBar . append ( createTab ( entry ) ) ;
218+ $secondTabBar . append ( createTab ( entry , "second-pane" ) ) ;
214219 Overflow . toggleOverflowVisibility ( "second-pane" ) ;
215220 setTimeout ( function ( ) {
216221 Overflow . scrollToActiveTab ( $secondTabBar ) ;
@@ -304,7 +309,7 @@ define(function (require, exports, module) {
304309 }
305310 }
306311 displayedEntries . forEach ( function ( entry ) {
307- $firstTabBar . append ( createTab ( entry ) ) ;
312+ $firstTabBar . append ( createTab ( entry , "first-pane" ) ) ;
308313 } ) ;
309314 }
310315 }
@@ -330,7 +335,7 @@ define(function (require, exports, module) {
330335 }
331336 }
332337 displayedEntries2 . forEach ( function ( entry ) {
333- $secondTabBar . append ( createTab ( entry ) ) ;
338+ $secondTabBar . append ( createTab ( entry , "second-pane" ) ) ;
334339 } ) ;
335340 }
336341 }
@@ -344,19 +349,30 @@ define(function (require, exports, module) {
344349 Helper . _hideTabBar ( $ ( '#phoenix-tab-bar-2' ) , $ ( '#overflow-button-2' ) ) ;
345350 }
346351
352+ const activePane = MainViewManager . getActivePaneId ( ) ;
353+
347354 // Now that tabs are updated, scroll to the active tab if necessary.
348355 if ( $firstTabBar . length ) {
349356 Overflow . toggleOverflowVisibility ( "first-pane" ) ;
350- setTimeout ( function ( ) {
351- Overflow . scrollToActiveTab ( $firstTabBar ) ;
352- } , 0 ) ;
357+
358+ // we scroll only in the active pane
359+ // this is because, lets say we have a same file in both the panes
360+ // then when the file is opened in one of the pane and is towards the end of the tab bar,
361+ // then we need to show the scrolling animation only on that pane and not on both the panes
362+ if ( activePane === "first-pane" ) {
363+ setTimeout ( function ( ) {
364+ Overflow . scrollToActiveTab ( $firstTabBar ) ;
365+ } , 0 ) ;
366+ }
353367 }
354368
355369 if ( $secondTabBar . length ) {
356370 Overflow . toggleOverflowVisibility ( "second-pane" ) ;
357- setTimeout ( function ( ) {
358- Overflow . scrollToActiveTab ( $secondTabBar ) ;
359- } , 0 ) ;
371+ if ( activePane === "second-pane" ) {
372+ setTimeout ( function ( ) {
373+ Overflow . scrollToActiveTab ( $secondTabBar ) ;
374+ } , 0 ) ;
375+ }
360376 }
361377
362378 // handle drag and drop
@@ -417,12 +433,6 @@ define(function (require, exports, module) {
417433 const filePath = $ ( this ) . attr ( "data-path" ) ;
418434
419435 if ( filePath ) {
420- // we need to determine which pane the tab belongs to
421- const isSecondPane = $ ( this ) . closest ( "#phoenix-tab-bar-2" ) . length > 0 ;
422- const paneId = isSecondPane ? "second-pane" : "first-pane" ;
423-
424- // Set the active pane and open the file
425- MainViewManager . setActivePaneId ( paneId ) ;
426436 CommandManager . execute ( Commands . FILE_OPEN , { fullPath : filePath } ) ;
427437
428438 // Prevent default behavior
0 commit comments