From e13a468f0c1ace548b7a985229fd1cf3d6426f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Garc=C3=ADa=20Sainz-Aja?= Date: Tue, 30 Aug 2022 09:38:41 +0200 Subject: [PATCH] fix: add read permissions to all workspace folders (#115) --- src/extension.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 716c093..780b627 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -46,16 +46,22 @@ function isAsyncAPIFile(text: string) { } function openAsyncAPI(context: vscode.ExtensionContext, uri: vscode.Uri) { + const localResourceRoots = [ + vscode.Uri.file(path.dirname(uri.fsPath)), + vscode.Uri.joinPath(context.extensionUri, 'dist/node_modules/@asyncapi/react-component/browser/standalone'), + vscode.Uri.joinPath(context.extensionUri, 'dist/node_modules/@asyncapi/react-component/styles'), + ]; + if (vscode.workspace.workspaceFolders) { + vscode.workspace.workspaceFolders.forEach(folder => { + localResourceRoots.push(folder.uri); + }); + } const panel: vscode.WebviewPanel = openAsyncapiFiles[uri.fsPath] || vscode.window.createWebviewPanel('asyncapi-preview', '', vscode.ViewColumn.Two, { enableScripts: true, retainContextWhenHidden: true, - localResourceRoots: [ - vscode.Uri.file(path.dirname(uri.fsPath)), - vscode.Uri.joinPath(context.extensionUri, 'dist/node_modules/@asyncapi/react-component/browser/standalone'), - vscode.Uri.joinPath(context.extensionUri, 'dist/node_modules/@asyncapi/react-component/styles'), - ], + localResourceRoots, }); panel.title = path.basename(uri.fsPath); panel.webview.html = getWebviewContent(context, panel.webview, uri);