Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle some URIs in new windows #146711

Merged
merged 4 commits into from Apr 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/vs/code/electron-main/app.ts
Expand Up @@ -876,9 +876,21 @@ export class CodeApplication extends Disposable {
return true;
}

// If we have not yet handled the URI and we have no window opened (macOS only)
// we first open a window and then try to open that URI within that window
if (isMacintosh && windowsMainService.getWindowCount() === 0) {
// We should handle the URI in a new window if no window is open (macOS only)
let shouldOpenInNewWindow = isMacintosh && windowsMainService.getWindowCount() === 0;

// or if the URL contains `windowId=_blank`
if (!shouldOpenInNewWindow) {
const params = new URLSearchParams(uri.query);

if (params.get('windowId') === '_blank') {
params.delete('windowId');
uri = uri.with({ query: params.toString() });
shouldOpenInNewWindow = true;
}
}

if (shouldOpenInNewWindow) {
const [window] = windowsMainService.open({
context: OpenContext.API,
cli: { ...environmentService.args },
Expand Down