@@ -2004,7 +2004,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<server
20042004
20052005// This function is exported as one of our API functions but is also used internally
20062006// for example to implement the async variant capable of resolving docker port number.
2007- function serverForUri ( uri : vscode . Uri ) : serverManager . ServerForUri {
2007+ function serverForUri ( uri : vscode . Uri ) : serverManager . ServerForUri | undefined {
20082008 const { apiTarget, configName } = connectionTarget ( uri ) ;
20092009 const configNameLower = configName . toLowerCase ( ) ;
20102010 const api = new AtelierAPI ( apiTarget ) ;
@@ -2030,27 +2030,32 @@ function serverForUri(uri: vscode.Uri): serverManager.ServerForUri {
20302030 )
20312031 . get ( "password" ) ;
20322032 password && auth . resolve ( { accessToken : password } ) ;
2033- return {
2034- serverName,
2035- active,
2036- ...( https ? ( { https : true , scheme : "https" } as const ) : ( { scheme : "http" } as const ) ) ,
2037- host,
2038- port,
2039- superserverPort,
2040- pathPrefix : pathPrefix ! ,
2041- auth,
2042- username : auth . username ,
2043- password : auth . password ,
2044- namespace : ns ! ,
2045- apiVersion : ( active ? apiVersion : undefined ) ! ,
2046- serverVersion : ( active ? serverVersion : undefined ) ! ,
2047- } ;
2033+ if ( ns ) {
2034+ return {
2035+ serverName,
2036+ active,
2037+ ...( https ? ( { https : true , scheme : "https" } as const ) : ( { scheme : "http" } as const ) ) ,
2038+ host,
2039+ port,
2040+ superserverPort,
2041+ pathPrefix : pathPrefix || "" ,
2042+ auth,
2043+ username : auth . username ,
2044+ password : auth . password ,
2045+ namespace : ns ,
2046+ apiVersion : ( active ? apiVersion : undefined ) ! ,
2047+ serverVersion : ( active ? serverVersion : undefined ) ! ,
2048+ } ;
2049+ }
20482050}
20492051
20502052// An async variant capable of resolving docker port number.
20512053// It is exported as one of our API functions but is also used internally.
2052- async function asyncServerForUri ( uri : vscode . Uri ) : Promise < serverManager . ServerForUri > {
2054+ async function asyncServerForUri ( uri : vscode . Uri ) : Promise < serverManager . ServerForUri | undefined > {
20532055 const server = serverForUri ( uri ) ;
2056+ if ( ! server ) {
2057+ return ;
2058+ }
20542059 if ( ! server . port ) {
20552060 let { apiTarget } = connectionTarget ( uri ) ;
20562061 if ( apiTarget instanceof vscode . Uri ) {
0 commit comments