Skip to content

Commit

Permalink
Handle some URIs in new windows (#146711)
Browse files Browse the repository at this point in the history
* handle URI in new windows

* make sure to remove the windowId query param
  • Loading branch information
joaomoreno committed Apr 4, 2022
1 parent 81d1f4d commit ea42ebd
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
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

0 comments on commit ea42ebd

Please sign in to comment.