From 9f2167a0eb8f8522770b19a9be13e05c871a6449 Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 8 Oct 2019 18:11:57 -0700 Subject: [PATCH 1/3] Update vscode dependency --- package-lock.json | 6 +++--- package.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6b4425355528..db164cab0189 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2382,9 +2382,9 @@ } }, "@types/vscode": { - "version": "1.36.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.36.0.tgz", - "integrity": "sha512-SbHR3Q5g/C3N+Ila3KrRf1rSZiyHxWdOZ7X3yFHXzw6HrvRLuVZrxnwEX0lTBMRpH9LkwZdqRTgXW+D075jxkg==", + "version": "1.38.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.38.0.tgz", + "integrity": "sha512-aGo8LQ4J1YF0T9ORuCO+bhQ5sGR1MXa7VOyOdEP685se3wyQWYUExcdiDi6rvaK61KUwfzzA19JRLDrUbDl7BQ==", "dev": true }, "@types/webpack": { diff --git a/package.json b/package.json index 2f3a70970ffd..834874e34dbe 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "theme": "dark" }, "engines": { - "vscode": "^1.36.0" + "vscode": "^1.38.0" }, "keywords": [ "python", @@ -2791,7 +2791,7 @@ "@types/tmp": "0.0.33", "@types/untildify": "^3.0.0", "@types/uuid": "^3.4.3", - "@types/vscode": "^1.36.0", + "@types/vscode": "^1.38.0", "@types/webpack-bundle-analyzer": "^2.13.0", "@types/winreg": "^1.2.30", "@types/ws": "^6.0.1", From 0f07b210437d6210a7bc941d3ab0f7a99a2dd63f Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 8 Oct 2019 18:13:35 -0700 Subject: [PATCH 2/3] News entry --- news/3 Code Health/7832.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/3 Code Health/7832.md diff --git a/news/3 Code Health/7832.md b/news/3 Code Health/7832.md new file mode 100644 index 000000000000..ee4faa776756 --- /dev/null +++ b/news/3 Code Health/7832.md @@ -0,0 +1 @@ +Update version of `@types/vscode`. From 5b0268d358ff7ac980072a7b630a98e364a70feb Mon Sep 17 00:00:00 2001 From: Don Jayamanne Date: Tue, 8 Oct 2019 18:19:12 -0700 Subject: [PATCH 3/3] Stop hardcoding 'vscode-resource' and use VSC api --- news/3 Code Health/7834.md | 1 + src/client/common/application/webPanel.ts | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) create mode 100644 news/3 Code Health/7834.md diff --git a/news/3 Code Health/7834.md b/news/3 Code Health/7834.md new file mode 100644 index 000000000000..3bd2421b2b27 --- /dev/null +++ b/news/3 Code Health/7834.md @@ -0,0 +1 @@ +Use `Webview.asWebviewUri` to generate a URI for use in the `Webview Panel` instead of hardcoding the resource `vscode-resource`. diff --git a/src/client/common/application/webPanel.ts b/src/client/common/application/webPanel.ts index 2e3bc5900e01..bf650a4656bb 100644 --- a/src/client/common/application/webPanel.ts +++ b/src/client/common/application/webPanel.ts @@ -5,8 +5,7 @@ import '../../common/extensions'; import * as fs from 'fs-extra'; import * as path from 'path'; -import { Uri, ViewColumn, WebviewPanel, window } from 'vscode'; - +import { Uri, ViewColumn, Webview, WebviewPanel, window } from 'vscode'; import * as localize from '../../common/utils/localize'; import { Identifiers } from '../../datascience/constants'; import { IServiceContainer } from '../../ioc/types'; @@ -89,7 +88,7 @@ export class WebPanel implements IWebPanel { // Call our special function that sticks this script inside of an html page // and translates all of the paths to vscode-resource URIs - this.panel.webview.html = this.generateReactHtml(mainScriptPath, embeddedCss, settings); + this.panel.webview.html = this.generateReactHtml(mainScriptPath, this.panel.webview, embeddedCss, settings); // Reset when the current panel is closed this.disposableRegistry.push(this.panel.onDidDispose(() => { @@ -118,11 +117,9 @@ export class WebPanel implements IWebPanel { } // tslint:disable-next-line:no-any - private generateReactHtml(mainScriptPath: string, embeddedCss?: string, settings?: any) { - const uriBasePath = Uri.file(`${path.dirname(mainScriptPath)}/`); - const uriPath = Uri.file(mainScriptPath); - const uriBase = uriBasePath.with({ scheme: 'vscode-resource' }); - const uri = uriPath.with({ scheme: 'vscode-resource' }); + private generateReactHtml(mainScriptPath: string, webView: Webview, embeddedCss?: string, settings?: any) { + const uriBase = webView.asWebviewUri(Uri.file(`${path.dirname(mainScriptPath)}/`)); + const uri = webView.asWebviewUri(Uri.file(mainScriptPath)); const locDatabase = localize.getCollectionJSON(); const style = embeddedCss ? embeddedCss : ''; const settingsString = settings ? JSON.stringify(settings) : '{}';