@@ -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 ) ;
@@ -657,6 +657,13 @@ export class ServerManagerView {
657657 } ) ) ;
658658 }
659659
660+ getTabByOrder (
661+ tabs : ServerOrFunctionalTab [ ] ,
662+ order : number ,
663+ ) : ServerOrFunctionalTab | undefined {
664+ return tabs . find ( ( tab ) => tab . properties . index === order ) ;
665+ }
666+
660667 async activateTab ( id : string , hideOldTab = true ) : Promise < void > {
661668 const tab = this . getTabById ( id ) ;
662669 if ( ! tab ) {
@@ -729,7 +736,10 @@ export class ServerManagerView {
729736
730737 // Issue #188: If the functional tab was not focused, do not activate another tab.
731738 if ( this . activeTabId === tabId ) {
732- await this . activateTab ( this . tabs [ 0 ] . properties . tabId , false ) ;
739+ await this . activateTab (
740+ this . getTabByOrder ( this . tabs , 0 ) ! . properties . tabId ,
741+ false ,
742+ ) ;
733743 }
734744 }
735745
0 commit comments