From 529e4fe0ded02f69fc56b3553b565127d608903d Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Mon, 30 Aug 2021 15:43:16 -0700 Subject: [PATCH] Fix ADS Web notebook cross linking (#16926) * fix cross linking files * use host location instead --- .../browser/cellViews/linkHandler.directive.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/sql/workbench/contrib/notebook/browser/cellViews/linkHandler.directive.ts b/src/sql/workbench/contrib/notebook/browser/cellViews/linkHandler.directive.ts index 3aff7fc0d0..9fc7524ea8 100644 --- a/src/sql/workbench/contrib/notebook/browser/cellViews/linkHandler.directive.ts +++ b/src/sql/workbench/contrib/notebook/browser/cellViews/linkHandler.directive.ts @@ -10,6 +10,7 @@ import { onUnexpectedError } from 'vs/base/common/errors'; import { INotebookService } from 'sql/workbench/services/notebook/browser/notebookService'; import { relative, resolve } from 'vs/base/common/path'; import { IFileService } from 'vs/platform/files/common/files'; +import { isWeb } from 'vs/base/common/platform'; const knownSchemes = new Set(['http', 'https', 'file', 'mailto', 'data', 'azuredatastudio', 'azuredatastudio-insiders', 'vscode', 'vscode-insiders', 'vscode-resource', 'onenote']); @Directive({ @@ -60,6 +61,16 @@ export class LinkHandlerDirective { } catch { // ignore } + // Web mode linking to open files + if (isWeb) { + // only change scheme for file links (file links in web mode scheme are also http) + // therefore we will use the authority to understand if its a local file path + if (window.location.host === uri.authority) { + uri = uri.with({ scheme: 'vscode-remote' }); + this.openerService.open(uri); + return; + } + } if (uri && this.openerService && this.isSupportedLink(uri)) { if (uri.fragment && uri.fragment.length > 0 && uri.fsPath === this.workbenchFilePath.fsPath) { this.notebookService.navigateTo(this.notebookUri, uri.fragment);