diff --git a/packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts b/packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts index 9b074d03eee07..3b81548c8b2ff 100644 --- a/packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts +++ b/packages/plugin-ext-vscode/src/node/plugin-vscode-init.ts @@ -18,6 +18,7 @@ import * as theia from '@theia/plugin'; import { BackendInitializationFn, PluginAPIFactory, Plugin, emptyPlugin } from '@theia/plugin-ext'; +import { ThemeService } from '@theia/core/src/browser/theming'; export const VSCODE_DEFAULT_API_VERSION = '1.33.1'; @@ -55,7 +56,7 @@ export const doInitialization: BackendInitializationFn = (apiFactory: PluginAPIF // redefine property Object.defineProperty(panel.webview, 'html', { set: function (html: string): void { - const newHtml = html.replace(new RegExp('vscode-resource:/', 'g'), 'webview/'); + const newHtml = relpaceWebViewContent(html); this.checkIsDisposed(); if (this._html !== newHtml) { this._html = newHtml; @@ -68,7 +69,7 @@ export const doInitialization: BackendInitializationFn = (apiFactory: PluginAPIF const originalPostMessage = panel.webview.postMessage; panel.webview.postMessage = (message: any): PromiseLike => { const decoded = JSON.stringify(message); - const newMessage = decoded.replace(new RegExp('vscode-resource:/', 'g'), 'webview/'); + const newMessage = relpaceWebViewContent(decoded); return originalPostMessage.call(panel.webview, JSON.parse(newMessage)); }; @@ -101,6 +102,10 @@ export const doInitialization: BackendInitializationFn = (apiFactory: PluginAPIF } }; +function relpaceWebViewContent(html: string): string { + return html.replace(new RegExp('vscode-resource:/', 'g'), 'webview/').replace(//, ``); +} + function overrideInternalLoad(): void { const module = require('module'); const vscodeModuleName = 'vscode';