Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a303bb8

Browse files
committedFeb 2, 2023
Open in existing window if no workspaces are opened
1 parent 110d186 commit a303bb8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

‎src/commands.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ export class Commands {
158158
// when opening a workspace unless explicitly specified.
159159
const remoteAuthority = `ssh-remote+${Remote.Prefix}${workspaceOwner}--${workspaceName}`
160160

161+
let newWindow = true
162+
// Open in the existing window if no workspaces are open.
163+
if (!vscode.workspace.workspaceFolders?.length) {
164+
newWindow = false
165+
}
166+
161167
const output: {
162168
workspaces: { folderUri: vscode.Uri; remoteAuthority: string }[]
163169
} = await vscode.commands.executeCommand("_workbench.getRecentlyOpened")
@@ -193,12 +199,15 @@ export class Commands {
193199
path: selected.folderUri.path,
194200
}),
195201
// Open this in a new window!
196-
true,
202+
newWindow,
197203
)
198204
return
199205
}
200206

201207
// This opens the workspace without an active folder opened.
202-
await vscode.commands.executeCommand("vscode.newWindow", { remoteAuthority: remoteAuthority, reuseWindow: false })
208+
await vscode.commands.executeCommand("vscode.newWindow", {
209+
remoteAuthority: remoteAuthority,
210+
reuseWindow: !newWindow,
211+
})
203212
}
204213
}

0 commit comments

Comments
 (0)
Please sign in to comment.