Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/3 Code Health/7832.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update version of `@types/vscode`.
1 change: 1 addition & 0 deletions news/3 Code Health/7834.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use `Webview.asWebviewUri` to generate a URI for use in the `Webview Panel` instead of hardcoding the resource `vscode-resource`.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"theme": "dark"
},
"engines": {
"vscode": "^1.36.0"
"vscode": "^1.38.0"
},
"keywords": [
"python",
Expand Down Expand Up @@ -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",
Expand Down
13 changes: 5 additions & 8 deletions src/client/common/application/webPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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) : '{}';
Expand Down