File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -461,8 +461,9 @@ export class AtelierAPI {
461461 if ( this . ns && this . ns . length && ! data . namespaces . includes ( this . ns ) && checkNs ) {
462462 throw {
463463 code : "WrongNamespace" ,
464- message : `This server does not have specified namespace '${ this . ns } '.\n
465- You must select one of the following: ${ data . namespaces . join ( ", " ) } .` ,
464+ message : `This server does not have specified namespace '${
465+ this . ns
466+ } '.\nYou must select one of the following: ${ data . namespaces . join ( ", " ) } .`,
466467 } ;
467468 }
468469 return Promise . all ( [
Original file line number Diff line number Diff line change @@ -73,12 +73,10 @@ export async function serverActions(): Promise<void> {
7373 break ;
7474 }
7575 case "switchNamespace" : {
76- // NOTE: List of all namespaces except the current one as it doesn't make sense to allow switching to the current one
77- const allNamespaces : string [ ] | undefined = await api
78- . serverInfo ( )
79- . then ( ( data ) =>
80- data . result . content . namespaces . filter ( ( ns ) => ns . toLowerCase ( ) !== api . config . ns . toLowerCase ( ) )
81- )
76+ // List of all namespaces except the current one as it doesn't make sense to allow switching to the current one
77+ let allNamespaces : string [ ] | undefined = await api
78+ . serverInfo ( false )
79+ . then ( ( data ) => data . result . content . namespaces )
8280 . catch ( ( error ) => {
8381 let message = `Failed to fetch a list of namespaces.` ;
8482 if ( error && error . errorText && error . errorText !== "" ) {
@@ -94,6 +92,13 @@ export async function serverActions(): Promise<void> {
9492 return ;
9593 }
9694
95+ if ( ! allNamespaces . length ) {
96+ vscode . window . showErrorMessage ( `You don't have access to any namespaces.` , "Dismiss" ) ;
97+ return ;
98+ }
99+
100+ // Filter out the current namespace
101+ allNamespaces = allNamespaces . filter ( ( ns ) => ns . toLowerCase ( ) != api . config . ns . toLowerCase ( ) ) ;
97102 if ( ! allNamespaces . length ) {
98103 vscode . window . showErrorMessage ( `You don't have access to any other namespaces.` , "Dismiss" ) ;
99104 return ;
You can’t perform that action at this time.
0 commit comments