From da186da376808075013c8988a652a831b7d74109 Mon Sep 17 00:00:00 2001 From: huangyanyan Date: Thu, 2 Feb 2023 16:10:10 +0800 Subject: [PATCH] Webview that not implements a WebviewPanelSerializer should not restore automatically after reconnecting. Signed-off-by: huangyanyan --- .../src/hosted/browser/hosted-plugin.ts | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts index 4433013af9f36..7ad4d14d07dde 100644 --- a/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts +++ b/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts @@ -778,22 +778,15 @@ export class HostedPluginSupport { protected async restoreWebview(webview: WebviewWidget): Promise { await this.activateByEvent(`onWebviewPanel:${webview.viewType}`); const restore = this.webviewRevivers.get(webview.viewType); - if (!restore) { - /* eslint-disable max-len */ - webview.setHTML(this.getDeserializationFailedContents(` -

The extension providing '${webview.viewType}' view is not capable of restoring it.

-

Want to help fix this? Please inform the extension developer to register a reviver.

- `)); - /* eslint-enable max-len */ - return; - } - try { - await restore(webview); - } catch (e) { - webview.setHTML(this.getDeserializationFailedContents(` - An error occurred while restoring '${webview.viewType}' view. Please check logs. - `)); - console.error('Failed to restore the webview', e); + if (restore) { + try { + await restore(webview); + } catch (e) { + webview.setHTML(this.getDeserializationFailedContents(` + An error occurred while restoring '${webview.viewType}' view. Please check logs. + `)); + console.error('Failed to restore the webview', e); + } } }