@@ -338,6 +338,9 @@ export function getResolvedConnectionSpec(key: string, dflt: any): any {
338338 return dflt ;
339339}
340340
341+ /** The `api.serverId`s of all servers that are known to be inactive */
342+ export const inactiveServerIds : Set < string > = new Set ( ) ;
343+
341344export async function checkConnection (
342345 clearCookies = false ,
343346 uri ?: vscode . Uri ,
@@ -432,9 +435,8 @@ export async function checkConnection(
432435 handleError ( message ) ;
433436 panel . text = `${ PANEL_LABEL } $(error)` ;
434437 panel . tooltip = `ERROR - ${ message } ` ;
435- if ( ! api . externalServer ) {
436- await setConnectionState ( configName , false ) ;
437- }
438+ inactiveServerIds . add ( api . serverId ) ;
439+ if ( ! api . externalServer ) await setConnectionState ( configName , false ) ;
438440 return ;
439441 }
440442 checkingConnection = true ;
@@ -448,9 +450,8 @@ export async function checkConnection(
448450 } else {
449451 panel . tooltip = new vscode . MarkdownString ( `Connected as \`${ username } \`` ) ;
450452 }
451- if ( ! api . externalServer ) {
452- await setConnectionState ( configName , true ) ;
453- }
453+ inactiveServerIds . delete ( api . serverId ) ;
454+ if ( ! api . externalServer ) await setConnectionState ( configName , true ) ;
454455 return ;
455456 } ;
456457
@@ -503,7 +504,8 @@ export async function checkConnection(
503504 } ) ;
504505 }
505506 } else {
506- await setConnectionState ( configName , false ) ;
507+ inactiveServerIds . add ( api . serverId ) ;
508+ if ( ! api . externalServer ) await setConnectionState ( configName , false ) ;
507509 }
508510 } else {
509511 success = await new Promise < boolean > ( ( resolve ) => {
@@ -535,8 +537,9 @@ export async function checkConnection(
535537 checkingConnection = false ;
536538 } )
537539 ) ;
538- } else if ( ! api . externalServer ) {
539- await setConnectionState ( configName , false ) ;
540+ } else {
541+ inactiveServerIds . add ( api . serverId ) ;
542+ if ( ! api . externalServer ) await setConnectionState ( configName , false ) ;
540543 }
541544 resolve ( false ) ;
542545 } ) ;
@@ -554,7 +557,8 @@ export async function checkConnection(
554557 ) ;
555558 panel . text = `${ connInfo } $(error)` ;
556559 panel . tooltip = `ERROR - ${ message } ` ;
557- await setConnectionState ( configName , false ) ;
560+ inactiveServerIds . add ( api . serverId ) ;
561+ if ( ! api . externalServer ) await setConnectionState ( configName , false ) ;
558562 } )
559563 . finally ( ( ) => {
560564 checkingConnection = false ;
0 commit comments