@@ -187,6 +187,43 @@ export function activate(context: vscode.ExtensionContext) {
187187 } )
188188 ) ;
189189
190+ const addWorkspaceFolderAsync = async ( readonly : boolean , namespaceTreeItem ?: ServerTreeItem ) => {
191+ if ( namespaceTreeItem ) {
192+ const pathParts = namespaceTreeItem . id ?. split ( ':' ) ;
193+ if ( pathParts && pathParts . length === 4 ) {
194+ const serverName = pathParts [ 1 ] ;
195+ const namespace = pathParts [ 3 ] ;
196+ const serverSpec = await getServerSpec ( serverName , undefined , undefined , true ) ;
197+ if ( serverSpec ) {
198+ const uri = vscode . Uri . parse ( `isfs${ readonly ? "-readonly" : "" } ://${ serverName } :${ namespace } /${ serverSpec . webServer . pathPrefix || '' } ` ) ;
199+ const label = `${ serverName } :${ namespace } ${ readonly ? " (read-only)" : "" } ` ;
200+ const added = vscode . workspace . updateWorkspaceFolders (
201+ vscode . workspace . workspaceFolders ? vscode . workspace . workspaceFolders . length : 0 ,
202+ 0 ,
203+ { uri, name : label }
204+ ) ;
205+ // Switch to Explorer view so user sees the outcome
206+ await vscode . commands . executeCommand ( "workbench.view.explorer" ) ;
207+ // Handle failure
208+ if ( added ) {
209+ await view . addToRecents ( serverName ) ;
210+ }
211+ else {
212+ vscode . window . showErrorMessage ( `Folder ${ uri . toString ( ) } could not be added. Maybe it already exists in the workspace.` , "Close" )
213+ }
214+ }
215+ }
216+ }
217+ }
218+
219+ context . subscriptions . push (
220+ vscode . commands . registerCommand ( `${ extensionId } .editNamespace` , async ( namespaceTreeItem ?: ServerTreeItem ) => { await addWorkspaceFolderAsync ( false , namespaceTreeItem ) } )
221+ ) ;
222+
223+ context . subscriptions . push (
224+ vscode . commands . registerCommand ( `${ extensionId } .viewNamespace` , async ( namespaceTreeItem ?: ServerTreeItem ) => { await addWorkspaceFolderAsync ( true , namespaceTreeItem ) } )
225+ ) ;
226+
190227 // Listen for relevant configuration changes
191228 context . subscriptions . push ( vscode . workspace . onDidChangeConfiguration ( e => {
192229 if ( e . affectsConfiguration ( 'intersystems.servers' ) || e . affectsConfiguration ( 'objectscript.conn' ) ) {
0 commit comments