From 13f73870fab13dcb4aaa9806a7e7aa489be42efc Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Sat, 27 Apr 2019 09:24:38 -0600 Subject: [PATCH] Fix error in HtmlContentView.ShowContent when no JS/CSS provided (#1925) --- src/features/CustomViews.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/features/CustomViews.ts b/src/features/CustomViews.ts index 155feca6dc..f5999877a7 100644 --- a/src/features/CustomViews.ts +++ b/src/features/CustomViews.ts @@ -207,12 +207,18 @@ class HtmlContentView extends CustomView { this.webviewPanel.dispose(); } - let localResourceRoots: vscode.Uri[] = this.htmlContent.javaScriptPaths.map((p) => { - return vscode.Uri.parse(path.dirname(p)); - }); - localResourceRoots = localResourceRoots.concat(this.htmlContent.styleSheetPaths.map((p) => { - return vscode.Uri.parse(path.dirname(p)); - })); + let localResourceRoots: vscode.Uri[] = []; + if (this.htmlContent.javaScriptPaths) { + localResourceRoots = localResourceRoots.concat(this.htmlContent.javaScriptPaths.map((p) => { + return vscode.Uri.parse(path.dirname(p)); + })); + } + + if (this.htmlContent.styleSheetPaths) { + localResourceRoots = localResourceRoots.concat(this.htmlContent.styleSheetPaths.map((p) => { + return vscode.Uri.parse(path.dirname(p)); + })); + } this.webviewPanel = vscode.window.createWebviewPanel( this.id,