@@ -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 (
@@ -210,22 +213,40 @@ export function activate(context: vscode.ExtensionContext) {
210
213
const namespace = pathParts [ 3 ] ;
211
214
const serverSpec = await getServerSpec ( serverName , undefined , undefined , true ) ;
212
215
if ( serverSpec ) {
213
- const uri = vscode . Uri . parse ( `isfs${ readonly ? "-readonly" : "" } ://${ serverName } :${ namespace } /${ serverSpec . webServer . pathPrefix || '' } ${ csp ? '?csp' : '' } ` ) ;
214
- const label = `${ serverName } :${ namespace } ${ csp ? ' webfiles' : '' } ${ readonly ? " (read-only)" : "" } ` ;
215
- const added = vscode . workspace . updateWorkspaceFolders (
216
- vscode . workspace . workspaceFolders ? vscode . workspace . workspaceFolders . length : 0 ,
217
- 0 ,
218
- { uri, name : label }
219
- ) ;
220
- // Switch to Explorer view so user sees the outcome
221
- await vscode . commands . executeCommand ( "workbench.view.explorer" ) ;
222
- // Handle failure
223
- if ( added ) {
224
- await view . addToRecents ( serverName ) ;
216
+ const ISFS_ID = 'intersystems-community.vscode-objectscript' ;
217
+ const isfsExtension = vscode . extensions . getExtension ( ISFS_ID ) ;
218
+ if ( isfsExtension ) {
219
+ if ( ! isfsExtension . isActive ) {
220
+ await isfsExtension . activate ( ) ;
221
+ if ( ! isfsExtension . isActive ) {
222
+ vscode . window . showErrorMessage ( `${ ISFS_ID } could not be activated.` , "Close" )
223
+ return ;
224
+ }
225
+ }
225
226
}
226
227
else {
227
- vscode . window . showErrorMessage ( `Folder ${ uri . toString ( ) } could not be added. Maybe it already exists in the workspace.` , "Close" )
228
+ vscode . window . showErrorMessage ( `${ ISFS_ID } is not installed.` , "Close" )
229
+ return ;
230
+ }
231
+
232
+ const uri = vscode . Uri . parse ( `isfs${ readonly ? "-readonly" : "" } ://${ serverName } :${ namespace } /${ serverSpec . webServer . pathPrefix || '' } ${ csp ? '?csp' : '' } ` ) ;
233
+ if ( ( vscode . workspace . workspaceFolders || [ ] ) . filter ( ( workspaceFolder ) => workspaceFolder . uri . toString ( ) === uri . toString ( ) ) . length === 0 ) {
234
+ const label = `${ serverName } :${ namespace } ${ csp ? ' webfiles' : '' } ${ 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
+ }
228
247
}
248
+ // Switch to Explorer view and focus on the folder
249
+ await vscode . commands . executeCommand ( "revealInExplorer" , uri ) ;
229
250
}
230
251
}
231
252
}
0 commit comments