@@ -55,7 +55,10 @@ export function activate(context: vscode.ExtensionContext) {
5555 ) ;
5656 context . subscriptions . push (
5757 vscode . commands . registerCommand ( `${ extensionId } .addServer` , async ( ) => {
58- await addServer ( ) ;
58+ const name = await addServer ( ) ;
59+ if ( name ) {
60+ await view . addToRecents ( name ) ;
61+ }
5962 } )
6063 ) ;
6164 context . subscriptions . push (
@@ -227,21 +230,23 @@ export function activate(context: vscode.ExtensionContext) {
227230 }
228231
229232 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+ }
244247 }
248+ // Switch to Explorer view and focus on the folder
249+ await vscode . commands . executeCommand ( "revealInExplorer" , uri ) ;
245250 }
246251 }
247252 }
0 commit comments