@@ -145,87 +145,6 @@ define(function (require, exports, module) {
145145 }
146146
147147
148- /**
149- * Sets up the tab bar
150- */
151- function setupTabBar ( ) {
152- // this populates the working sets present in `global.js`
153- getAllFilesFromWorkingSet ( ) ;
154-
155- // if no files are present in a pane, we want to hide the tab bar for that pane
156- const $firstTabBar = $ ( '#phoenix-tab-bar' ) ;
157- const $secondTabBar = $ ( '#phoenix-tab-bar-2' ) ;
158-
159- if ( Global . firstPaneWorkingSet . length === 0 && ( $ ( '#phoenix-tab-bar' ) ) ) {
160- Helper . _hideTabBar ( $ ( '#phoenix-tab-bar' ) , $ ( '#overflow-button' ) ) ;
161- }
162-
163- if ( Global . secondPaneWorkingSet . length === 0 && ( $ ( '#phoenix-tab-bar-2' ) ) ) {
164- Helper . _hideTabBar ( $ ( '#phoenix-tab-bar-2' ) , $ ( '#overflow-button-2' ) ) ;
165- }
166-
167- // get the count of tabs that we want to display in the tab bar (from preference settings)
168- // from preference settings or working set whichever smaller
169- let tabsCountP1 = Math . min ( Global . firstPaneWorkingSet . length , Preference . tabBarNumberOfTabs ) ;
170- let tabsCountP2 = Math . min ( Global . secondPaneWorkingSet . length , Preference . tabBarNumberOfTabs ) ;
171-
172- // the value is generally '-1', but we check for less than 0 so that it can handle edge cases gracefully
173- // if the value is negative then we display all tabs
174- if ( Preference . tabBarNumberOfTabs < 0 ) {
175- tabsCountP1 = Global . firstPaneWorkingSet . length ;
176- tabsCountP2 = Global . secondPaneWorkingSet . length ;
177- }
178-
179- // get the active editor and path once to reuse for both panes
180- const activeEditor = EditorManager . getActiveEditor ( ) ;
181- const activePath = activeEditor ? activeEditor . document . file . fullPath : null ;
182-
183- // handle the first pane tabs
184- if ( Global . firstPaneWorkingSet . length > 0 && tabsCountP1 > 0 && $firstTabBar . length ) {
185- // get the top n entries for the first pane
186- let displayedEntries = Global . firstPaneWorkingSet . slice ( 0 , tabsCountP1 ) ;
187-
188- // if the active file isn't already visible but exists in the working set, force-include it
189- if ( activePath && ! displayedEntries . some ( entry => entry . path === activePath ) ) {
190- let activeEntry = Global . firstPaneWorkingSet . find ( entry => entry . path === activePath ) ;
191- if ( activeEntry ) {
192- // replace the last tab with the active file.
193- displayedEntries [ displayedEntries . length - 1 ] = activeEntry ;
194- }
195- }
196-
197- // add each tab to the first pane's tab bar
198- displayedEntries . forEach ( function ( entry ) {
199- $firstTabBar . append ( createTab ( entry , "first-pane" ) ) ;
200- Overflow . toggleOverflowVisibility ( "first-pane" ) ;
201- setTimeout ( function ( ) {
202- Overflow . scrollToActiveTab ( $firstTabBar ) ;
203- } , 0 ) ;
204- } ) ;
205- }
206-
207- // for second pane tabs
208- if ( Global . secondPaneWorkingSet . length > 0 && tabsCountP2 > 0 && $secondTabBar . length ) {
209- let displayedEntries2 = Global . secondPaneWorkingSet . slice ( 0 , tabsCountP2 ) ;
210-
211- if ( activePath && ! displayedEntries2 . some ( entry => entry . path === activePath ) ) {
212- let activeEntry = Global . secondPaneWorkingSet . find ( entry => entry . path === activePath ) ;
213- if ( activeEntry ) {
214- displayedEntries2 [ displayedEntries2 . length - 1 ] = activeEntry ;
215- }
216- }
217-
218- displayedEntries2 . forEach ( function ( entry ) {
219- $secondTabBar . append ( createTab ( entry , "second-pane" ) ) ;
220- Overflow . toggleOverflowVisibility ( "second-pane" ) ;
221- setTimeout ( function ( ) {
222- Overflow . scrollToActiveTab ( $secondTabBar ) ;
223- } , 0 ) ;
224- } ) ;
225- }
226- }
227-
228-
229148 /**
230149 * Creates the tab bar and adds it to the DOM
231150 */
@@ -255,8 +174,6 @@ define(function (require, exports, module) {
255174 WorkspaceManager . recomputeLayout ( true ) ;
256175 updateTabs ( ) ;
257176 }
258-
259- setupTabBar ( ) ;
260177 }
261178
262179
@@ -507,29 +424,33 @@ define(function (require, exports, module) {
507424 const filePath = doc . file . fullPath ;
508425
509426 // Update UI
510- const $tab = $tabBar . find ( `.tab[data-path="${ filePath } "]` ) ;
511- $tab . toggleClass ( 'dirty' , doc . isDirty ) ;
427+ if ( $tabBar ) {
428+ const $tab = $tabBar . find ( `.tab[data-path="${ filePath } "]` ) ;
429+ $tab . toggleClass ( 'dirty' , doc . isDirty ) ;
430+
431+
432+ // Update the working set data
433+ // First pane
434+ for ( let i = 0 ; i < Global . firstPaneWorkingSet . length ; i ++ ) {
435+ if ( Global . firstPaneWorkingSet [ i ] . path === filePath ) {
436+ Global . firstPaneWorkingSet [ i ] . isDirty = doc . isDirty ;
437+ break ;
438+ }
439+ }
440+ }
441+
512442
513443 // Also update the $tab2 if it exists
514444 if ( $tabBar2 ) {
515445 const $tab2 = $tabBar2 . find ( `.tab[data-path="${ filePath } "]` ) ;
516446 $tab2 . toggleClass ( 'dirty' , doc . isDirty ) ;
517- }
518-
519- // Update the working set data
520- // First pane
521- for ( let i = 0 ; i < Global . firstPaneWorkingSet . length ; i ++ ) {
522- if ( Global . firstPaneWorkingSet [ i ] . path === filePath ) {
523- Global . firstPaneWorkingSet [ i ] . isDirty = doc . isDirty ;
524- break ;
525- }
526- }
527447
528- // Second pane
529- for ( let i = 0 ; i < Global . secondPaneWorkingSet . length ; i ++ ) {
530- if ( Global . secondPaneWorkingSet [ i ] . path === filePath ) {
531- Global . secondPaneWorkingSet [ i ] . isDirty = doc . isDirty ;
532- break ;
448+ // Second pane
449+ for ( let i = 0 ; i < Global . secondPaneWorkingSet . length ; i ++ ) {
450+ if ( Global . secondPaneWorkingSet [ i ] . path === filePath ) {
451+ Global . secondPaneWorkingSet [ i ] . isDirty = doc . isDirty ;
452+ break ;
453+ }
533454 }
534455 }
535456 } ) ;
0 commit comments