From 5693b09a67ebf6735c01cfa99b29120e60f9c7b6 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Fri, 20 Sep 2019 13:41:29 -0700 Subject: [PATCH] Extract shouldOpenExternal --- src/vs/workbench/electron-browser/window.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index 469ed67fadf..de41b59bb72 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -423,9 +423,7 @@ export class ElectronWindow extends Disposable { // scheme is one where we prefer to open externally // we handle this resource by delegating the opening to // the main process to prevent window focus issues. - const scheme = resource.scheme.toLowerCase(); - const preferOpenExternal = (scheme === Schemas.mailto || scheme === Schemas.http || scheme === Schemas.https); - if ((options && options.openExternal) || preferOpenExternal) { + if ($this.shouldOpenExternal(resource, options)) { const success = await $this.windowsService.openExternal(encodeURI(resource.toString(true))); if (!success && resource.scheme === Schemas.file) { // if opening failed, and this is a file, we can still try to reveal it @@ -440,6 +438,12 @@ export class ElectronWindow extends Disposable { }); } + private shouldOpenExternal(resource: URI, options?: { openToSide?: boolean; openExternal?: boolean; }) { + const scheme = resource.scheme.toLowerCase(); + const preferOpenExternal = (scheme === Schemas.mailto || scheme === Schemas.http || scheme === Schemas.https); + return (options && options.openExternal) || preferOpenExternal; + } + private updateTouchbarMenu(): void { if (!isMacintosh) { return; // macOS only -- GitLab