Skip to content

Commit

Permalink
Merge pull request #77 from gjsjohnmurray/fix-76
Browse files Browse the repository at this point in the history
fix #76 handle repeated 'Edit / Show Code in Namespace' actions
  • Loading branch information
gjsjohnmurray authored Apr 21, 2021
2 parents a667dd6 + 03104d5 commit 89b872c
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 89b872c

Please sign in to comment.