@@ -55,7 +55,10 @@ export function activate(context: vscode.ExtensionContext) {
55
55
) ;
56
56
context . subscriptions . push (
57
57
vscode . commands . registerCommand ( `${ extensionId } .addServer` , async ( ) => {
58
- await addServer ( ) ;
58
+ const name = await addServer ( ) ;
59
+ if ( name ) {
60
+ await view . addToRecents ( name ) ;
61
+ }
59
62
} )
60
63
) ;
61
64
context . subscriptions . push (
@@ -227,21 +230,23 @@ export function activate(context: vscode.ExtensionContext) {
227
230
}
228
231
229
232
const uri = vscode . Uri . parse ( `isfs${ readonly ? "-readonly" : "" } ://${ serverName } :${ namespace } /${ serverSpec . webServer . pathPrefix || '' } ` ) ;
230
- const label = ` ${ serverName } : ${ namespace } ${ readonly ? " (read-only)" : "" } ` ;
231
- const added = vscode . workspace . updateWorkspaceFolders (
232
- vscode . workspace . workspaceFolders ? vscode . workspace . workspaceFolders . length : 0 ,
233
- 0 ,
234
- { uri , name : label }
235
- ) ;
236
- // Switch to Explorer view so user sees the outcome
237
- await vscode . commands . executeCommand ( "workbench.view.explorer" ) ;
238
- // Handle failure
239
- if ( added ) {
240
- await view . addToRecents ( serverName ) ;
241
- }
242
- else {
243
- vscode . window . showErrorMessage ( `Folder ${ uri . toString ( ) } could not be added. Maybe it already exists in the workspace.` , "Close" )
233
+ if ( ( vscode . workspace . workspaceFolders || [ ] ) . filter ( ( workspaceFolder ) => workspaceFolder . uri . toString ( ) === uri . toString ( ) ) . length === 0 ) {
234
+ const label = ` ${ serverName } : ${ namespace } ${ readonly ? " (read-only)" : "" } ` ;
235
+ const added = vscode . workspace . updateWorkspaceFolders (
236
+ vscode . workspace . workspaceFolders ? vscode . workspace . workspaceFolders . length : 0 ,
237
+ 0 ,
238
+ { uri , name : label }
239
+ ) ;
240
+ // Handle failure
241
+ if ( added ) {
242
+ await view . addToRecents ( serverName ) ;
243
+ }
244
+ else {
245
+ vscode . window . showErrorMessage ( `Folder ${ uri . toString ( ) } could not be added.` , "Close" )
246
+ }
244
247
}
248
+ // Switch to Explorer view and focus on the folder
249
+ await vscode . commands . executeCommand ( "revealInExplorer" , uri ) ;
245
250
}
246
251
}
247
252
}
0 commit comments