Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ export class BrowserEditorInput extends EditorInput {
}

override get resource(): URI {
if (this._resourceBeforeDisposal) {
return this._resourceBeforeDisposal;
}

return BrowserViewUri.forId(this._id);
}

Expand Down Expand Up @@ -288,16 +284,12 @@ export class BrowserEditorInput extends EditorInput {
};
}

// When closing the editor, toUntyped() is called after dispose().
// So we save a snapshot of the resource so we can still use it after the model is disposed.
private _resourceBeforeDisposal: URI | undefined;
override dispose(): void {
super.dispose(); // Emit `onWillDispose` event first, then clean up the model.
if (this._model) {
this._resourceBeforeDisposal = this.resource;
this._model.dispose();
this._model = undefined;
}
super.dispose();
}

serialize(): IBrowserEditorInputData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,12 @@ export class BrowserEditor extends EditorPane {
});
this.setBackgroundImage(this._model.screenshot);

// When closing a tab, the model gets disposed before the editor input is cleared.
// So we make sure we don't keep a reference to the disposed model.
this._inputDisposables.add(this._model.onWillDispose(() => {
this._model = undefined;
}));

// Start / stop screenshots when the model visibility changes
this._inputDisposables.add(this._model.onDidChangeVisibility(() => this.doScreenshot()));

Expand Down
Loading