@@ -112,7 +112,41 @@ export function commonActivate(context: vscode.ExtensionContext, view: ServerMan
112
112
view . refreshTree ( ) ;
113
113
} ) ,
114
114
vscode . commands . registerCommand ( `${ extensionId } .addServer` , async ( ) => {
115
- const name = await addServer ( ) ;
115
+ let scope : vscode . ConfigurationScope | undefined ;
116
+ let target : vscode . ConfigurationTarget | undefined ;
117
+ if ( vscode . workspace . workspaceFolders ) {
118
+ interface SettingsScope extends vscode . QuickPickItem {
119
+ scope ?: vscode . ConfigurationScope ;
120
+ target : vscode . ConfigurationTarget ;
121
+ }
122
+ const options : SettingsScope [ ] = [ { label : "Global" , detail : "User Settings" , target : vscode . ConfigurationTarget . Global } ] ;
123
+ if ( vscode . workspace . workspaceFile ) {
124
+ // The workspace is a file, so each folder may be its own option
125
+ options . push (
126
+ { label : "Workspace" , detail : vscode . workspace . workspaceFile . toString ( true ) , target : vscode . ConfigurationTarget . Workspace } ,
127
+ ...vscode . workspace . workspaceFolders
128
+ . filter ( f => ! [ "isfs" , "isfs-readonly" ] . includes ( f . uri . scheme ) )
129
+ . map ( f => {
130
+ return { label : f . name , detail : f . uri . toString ( true ) , scope : f , target : vscode . ConfigurationTarget . WorkspaceFolder } ;
131
+ } )
132
+ ) ;
133
+ } else {
134
+ // The workspace is a single local folder, so that is the only other option
135
+ options . push ( { label : "Workspace" , detail : vscode . workspace . workspaceFolders [ 0 ] ?. uri . toString ( true ) ?? "Current folder" , target : vscode . ConfigurationTarget . Workspace } ) ;
136
+ }
137
+ const choice = await vscode . window . showQuickPick ( options , {
138
+ ignoreFocusOut : true ,
139
+ title : "Pick a settngs scope in which to add the server definition"
140
+ } ) ;
141
+ if ( ! choice ) return ;
142
+ scope = choice . scope ;
143
+ target = choice . target ;
144
+ } else {
145
+ // No workspace is open, so global is the only option
146
+ scope = undefined ;
147
+ target = vscode . ConfigurationTarget . Global ;
148
+ }
149
+ const name = await addServer ( scope , target ) ;
116
150
if ( name ) {
117
151
await view . addToRecents ( name ) ;
118
152
}
0 commit comments