diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 5d6b367dca09f..82260d4a427a9 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -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 },