Skip to content

Commit

Permalink
Merge branch 'main' into fix-80
Browse files Browse the repository at this point in the history
  • Loading branch information
gjsjohnmurray committed Apr 22, 2021
2 parents aa36bb5 + 6579cfa commit 88ed794
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -227,21 +230,23 @@ export function activate(context: vscode.ExtensionContext) {
}

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 88ed794

Please sign in to comment.