Add serializer for simple browser

Fixes #119057
This commit is contained in:
Matt Bierner
2021-10-07 16:49:11 -07:00
parent f542a0e83a
commit 62d631a165
5 changed files with 53 additions and 15 deletions

View File

@@ -23,16 +23,27 @@ export class SimpleBrowserManager {
if (this._activeView) {
this._activeView.show(url, options);
} else {
const view = new SimpleBrowserView(this.extensionUri, url, options);
view.onDispose(() => {
if (this._activeView === view) {
this._activeView = undefined;
}
});
const view = SimpleBrowserView.create(this.extensionUri, url, options);
this.registerWebviewListeners(view);
this._activeView = view;
}
}
public restore(panel: vscode.WebviewPanel, state: any): void {
const url = state?.url ?? '';
const view = SimpleBrowserView.restore(this.extensionUri, url, panel);
this.registerWebviewListeners(view);
return;
}
private registerWebviewListeners(view: SimpleBrowserView) {
view.onDispose(() => {
if (this._activeView === view) {
this._activeView = undefined;
}
});
}
}