From 03104d51ff30732d4c055ec54078056ba40bffb5 Mon Sep 17 00:00:00 2001 From: gjsjohnmurray Date: Wed, 21 Apr 2021 17:37:40 +0100 Subject: [PATCH 1/3] fix #76 handle repeated 'Edit / Show Code in Namespace' actions --- src/extension.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 99a6bda..3f02072 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -211,21 +211,23 @@ export function activate(context: vscode.ExtensionContext) { const serverSpec = await getServerSpec(serverName, undefined, undefined, true); if (serverSpec) { const uri = vscode.Uri.parse(`isfs${readonly ? "-readonly" : ""}://${serverName}:${namespace}/${serverSpec.webServer.pathPrefix || ''}`); - const label = `${serverName}:${namespace}${readonly ? " (read-only)" : ""}`; - const added = vscode.workspace.updateWorkspaceFolders( - vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders.length : 0, - 0, - { uri, name: label } - ); - // Switch to Explorer view so user sees the outcome - await vscode.commands.executeCommand("workbench.view.explorer"); - // Handle failure - if (added) { - await view.addToRecents(serverName); - } - else { - vscode.window.showErrorMessage(`Folder ${uri.toString()} could not be added. Maybe it already exists in the workspace.`, "Close") + if ((vscode.workspace.workspaceFolders || []).filter((workspaceFolder) => workspaceFolder.uri.toString() === uri.toString()).length === 0) { + const label = `${serverName}:${namespace}${readonly ? " (read-only)" : ""}`; + const added = vscode.workspace.updateWorkspaceFolders( + vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders.length : 0, + 0, + { uri, name: label } + ); + // Handle failure + if (added) { + await view.addToRecents(serverName); + } + else { + vscode.window.showErrorMessage(`Folder ${uri.toString()} could not be added.`, "Close") + } } + // Switch to Explorer view and focus on the folder + await vscode.commands.executeCommand("revealInExplorer", uri); } } } From b4477fa275df0a7252833c60227c9026f6224fe7 Mon Sep 17 00:00:00 2001 From: gjsjohnmurray Date: Wed, 21 Apr 2021 18:12:42 +0100 Subject: [PATCH 2/3] fix #78 add new server to top of Recent folder --- src/extension.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 99a6bda..4126c67 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -55,7 +55,10 @@ export function activate(context: vscode.ExtensionContext) { ); context.subscriptions.push( vscode.commands.registerCommand(`${extensionId}.addServer`, async () => { - await addServer(); + const name = await addServer(); + if (name) { + await view.addToRecents(name); + } }) ); context.subscriptions.push( From aa36bb591647c8d2ee560e9227509e0d271d806f Mon Sep 17 00:00:00 2001 From: gjsjohnmurray Date: Wed, 21 Apr 2021 22:14:41 +0100 Subject: [PATCH 3/3] fix #80 before adding isfs folder, check vscode-objectscript extension is available --- src/extension.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index 99a6bda..22e271c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -210,6 +210,22 @@ export function activate(context: vscode.ExtensionContext) { const namespace = pathParts[3]; const serverSpec = await getServerSpec(serverName, undefined, undefined, true); if (serverSpec) { + const ISFS_ID = 'intersystems-community.vscode-objectscript'; + const isfsExtension = vscode.extensions.getExtension(ISFS_ID); + if (isfsExtension) { + if (!isfsExtension.isActive) { + await isfsExtension.activate(); + if (!isfsExtension.isActive) { + vscode.window.showErrorMessage(`${ISFS_ID} could not be activated.`, "Close") + return; + } + } + } + else { + vscode.window.showErrorMessage(`${ISFS_ID} is not installed.`, "Close") + return; + } + const uri = vscode.Uri.parse(`isfs${readonly ? "-readonly" : ""}://${serverName}:${namespace}/${serverSpec.webServer.pathPrefix || ''}`); const label = `${serverName}:${namespace}${readonly ? " (read-only)" : ""}`; const added = vscode.workspace.updateWorkspaceFolders(