Make sure we dispose/track disposed webviews in webview views

Fixes #106826
This commit is contained in:
Matt Bierner
2020-09-16 15:33:10 -07:00
parent 4799714403
commit d29fc5038a
3 changed files with 12 additions and 2 deletions

View File

@@ -54,6 +54,8 @@ export class ExtHostWebview implements vscode.Webview {
/* internal */ readonly _onDidDispose: Event<void> = this.#onDidDisposeEmitter.event;
public dispose() {
this.#isDisposed = true;
this.#onDidDisposeEmitter.fire();
this.#onDidDisposeEmitter.dispose();
@@ -99,8 +101,10 @@ export class ExtHostWebview implements vscode.Webview {
this.#options = newOptions;
}
public postMessage(message: any): Promise<boolean> {
this.assertNotDisposed();
public async postMessage(message: any): Promise<boolean> {
if (this.#isDisposed) {
return false;
}
return this.#proxy.$postMessage(this.#handle, message);
}