Skip to content

Commit

Permalink
Merge pull request #85289 from jzyrobert/85046_windows_protocol_handler
Browse files Browse the repository at this point in the history
Add appRoot to windows protocol handler for dev
  • Loading branch information
joaomoreno authored Nov 28, 2019
2 parents 100eead + b8ecf87 commit 17f381f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export class CodeApplication extends Disposable {
// Watch Electron URLs and forward them to the UrlService
const args = this.environmentService.args;
const urls = args['open-url'] ? args._urls : [];
const urlListener = new ElectronURLListener(urls || [], urlService, windowsMainService);
const urlListener = new ElectronURLListener(urls || [], urlService, windowsMainService, this.environmentService);
this._register(urlListener);

// Open our first window
Expand Down
8 changes: 6 additions & 2 deletions src/vs/platform/url/electron-main/electronUrlListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { Event } from 'vs/base/common/event';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IURLService } from 'vs/platform/url/common/url';
import product from 'vs/platform/product/common/product';
import { app, Event as ElectronEvent } from 'electron';
Expand Down Expand Up @@ -32,7 +33,8 @@ export class ElectronURLListener {
constructor(
initial: string | string[],
@IURLService private readonly urlService: IURLService,
@IWindowsMainService windowsMainService: IWindowsMainService
@IWindowsMainService windowsMainService: IWindowsMainService,
@IEnvironmentService environmentService: IEnvironmentService
) {
const globalBuffer = ((<any>global).getOpenUrls() || []) as string[];
const rawBuffer = [
Expand All @@ -43,7 +45,9 @@ export class ElectronURLListener {
this.uris = coalesce(rawBuffer.map(uriFromRawUrl));

if (isWindows) {
app.setAsDefaultProtocolClient(product.urlProtocol, process.execPath, ['--open-url', '--']);
const windowsParameters = environmentService.isBuilt ? [] : [`"${environmentService.appRoot}"`];
windowsParameters.push('--open-url', '--');
app.setAsDefaultProtocolClient(product.urlProtocol, process.execPath, windowsParameters);
}

const onOpenElectronUrl = Event.map(
Expand Down

0 comments on commit 17f381f

Please sign in to comment.