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 {
461
461
if ( this . ns && this . ns . length && ! data . namespaces . includes ( this . ns ) && checkNs ) {
462
462
throw {
463
463
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 ( ", " ) } .`,
466
467
} ;
467
468
}
468
469
return Promise . all ( [
Original file line number Diff line number Diff line change @@ -73,12 +73,10 @@ export async function serverActions(): Promise<void> {
73
73
break ;
74
74
}
75
75
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 )
82
80
. catch ( ( error ) => {
83
81
let message = `Failed to fetch a list of namespaces.` ;
84
82
if ( error && error . errorText && error . errorText !== "" ) {
@@ -94,6 +92,13 @@ export async function serverActions(): Promise<void> {
94
92
return ;
95
93
}
96
94
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 ( ) ) ;
97
102
if ( ! allNamespaces . length ) {
98
103
vscode . window . showErrorMessage ( `You don't have access to any other namespaces.` , "Dismiss" ) ;
99
104
return ;
You can’t perform that action at this time.
0 commit comments