mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Make sure we don't try posting mesages to disposed markdown previews
Fixes #45553
This commit is contained in:
parent
d855ec8060
commit
5b90e42e3c
|
@ -28,6 +28,8 @@ export class MarkdownPreview {
|
|||
private currentVersion?: { resource: vscode.Uri, version: number };
|
||||
private forceUpdate = false;
|
||||
private isScrolling = false;
|
||||
private _disposed: boolean = false;
|
||||
|
||||
|
||||
public static async revive(
|
||||
webview: vscode.Webview,
|
||||
|
@ -141,7 +143,7 @@ export class MarkdownPreview {
|
|||
|
||||
vscode.window.onDidChangeTextEditorSelection(event => {
|
||||
if (this.isPreviewOf(event.textEditor.document.uri)) {
|
||||
this.webview.postMessage({
|
||||
this.postMessage({
|
||||
type: 'onDidChangeTextEditorSelection',
|
||||
line: event.selections[0].active.line,
|
||||
source: this.resource.toString()
|
||||
|
@ -169,6 +171,11 @@ export class MarkdownPreview {
|
|||
}
|
||||
|
||||
public dispose() {
|
||||
if (this._disposed) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._disposed = true;
|
||||
this._onDisposeEmitter.fire();
|
||||
|
||||
this._onDisposeEmitter.dispose();
|
||||
|
@ -276,7 +283,7 @@ export class MarkdownPreview {
|
|||
if (typeof topLine === 'number') {
|
||||
this.logger.log('updateForView', { markdownFile: resource });
|
||||
this.line = topLine;
|
||||
this.webview.postMessage({
|
||||
this.postMessage({
|
||||
type: 'updateView',
|
||||
line: topLine,
|
||||
source: resource.toString()
|
||||
|
@ -284,6 +291,12 @@ export class MarkdownPreview {
|
|||
}
|
||||
}
|
||||
|
||||
private postMessage(msg: any) {
|
||||
if (!this._disposed) {
|
||||
this.webview.postMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
private async doUpdate(): Promise<void> {
|
||||
const resource = this._resource;
|
||||
|
||||
|
|
Loading…
Reference in a new issue