From 110d1863f261f79badb83f1861984250be8e3a7c Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Thu, 2 Feb 2023 08:54:27 -0600 Subject: [PATCH 1/2] fix: open workspaces in new windows Fixes coder/coder#5703 --- src/commands.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commands.ts b/src/commands.ts index 0b82d558..fdd7c152 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -192,11 +192,13 @@ export class Commands { authority: remoteAuthority, path: selected.folderUri.path, }), + // Open this in a new window! + true, ) return } // This opens the workspace without an active folder opened. - await vscode.commands.executeCommand("vscode.newWindow", { remoteAuthority: remoteAuthority, reuseWindow: true }) + await vscode.commands.executeCommand("vscode.newWindow", { remoteAuthority: remoteAuthority, reuseWindow: false }) } } From a303bb8542b07a74157500a4b601c6fd859c7ad2 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Thu, 2 Feb 2023 09:30:23 -0600 Subject: [PATCH 2/2] Open in existing window if no workspaces are opened --- src/commands.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index fdd7c152..3d29fd0f 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -158,6 +158,12 @@ export class Commands { // when opening a workspace unless explicitly specified. const remoteAuthority = `ssh-remote+${Remote.Prefix}${workspaceOwner}--${workspaceName}` + let newWindow = true + // Open in the existing window if no workspaces are open. + if (!vscode.workspace.workspaceFolders?.length) { + newWindow = false + } + const output: { workspaces: { folderUri: vscode.Uri; remoteAuthority: string }[] } = await vscode.commands.executeCommand("_workbench.getRecentlyOpened") @@ -193,12 +199,15 @@ export class Commands { path: selected.folderUri.path, }), // Open this in a new window! - true, + newWindow, ) return } // This opens the workspace without an active folder opened. - await vscode.commands.executeCommand("vscode.newWindow", { remoteAuthority: remoteAuthority, reuseWindow: false }) + await vscode.commands.executeCommand("vscode.newWindow", { + remoteAuthority: remoteAuthority, + reuseWindow: !newWindow, + }) } }