@@ -333,7 +333,7 @@ export class ServerManagerView {
333333 }
334334
335335 // Open last active tab
336- const firstTab = this . tabs [ 0 ] ;
336+ const firstTab = this . getTabByOrder ( this . tabs , 0 ) ! ;
337337 const lastActiveTabId = ConfigUtil . getConfigItem (
338338 "lastActiveTabId" ,
339339 firstTab . properties . tabId ,
@@ -346,14 +346,14 @@ export class ServerManagerView {
346346 // `webview.load()` for lastActiveTabId before the others
347347 await this . activateTab ( lastActiveTabId ) ;
348348 await Promise . all (
349- servers . map ( async ( server , i ) => {
349+ servers . map ( async ( server ) => {
350350 // After the lastActiveTabId is activated, we load the others in the background
351351 // without activating them, to prevent flashing of server icons
352352 if ( server . id === lastActiveTabId ) {
353353 return ;
354354 }
355355
356- const tab = this . tabs [ i ] ;
356+ const tab = this . getTabById ( server . id ) ;
357357 if ( tab instanceof ServerTab ) ( await tab . webview ) . load ( ) ;
358358 } ) ,
359359 ) ;
@@ -660,6 +660,13 @@ export class ServerManagerView {
660660 return this . tabs . map ( ( tab ) => this . tabForIpc ( tab ) ) ;
661661 }
662662
663+ getTabByOrder (
664+ tabs : ServerOrFunctionalTab [ ] ,
665+ order : number ,
666+ ) : ServerOrFunctionalTab | undefined {
667+ return tabs . find ( ( tab ) => tab . properties . index === order ) ;
668+ }
669+
663670 async activateTab ( id : string , hideOldTab = true ) : Promise < void > {
664671 const tab = this . getTabById ( id ) ;
665672 if ( ! tab ) {
@@ -737,7 +744,10 @@ export class ServerManagerView {
737744 // Issue #188: If the functional tab was not focused, do not activate another tab.
738745 if ( wasActive ) {
739746 this . activeTab = undefined ;
740- await this . activateTab ( this . tabs [ 0 ] . properties . tabId , false ) ;
747+ await this . activateTab (
748+ this . getTabByOrder ( this . tabs , 0 ) ! . properties . tabId ,
749+ false ,
750+ ) ;
741751 }
742752 }
743753
0 commit comments