Skip to content

Commit

Permalink
Fix disposing editor's plot client
Browse files Browse the repository at this point in the history
  • Loading branch information
timtmok committed Aug 30, 2024
1 parent c620eb9 commit b72be8f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { WebviewPlotClient } from 'vs/workbench/contrib/positronPlots/browser/we
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { URI } from 'vs/base/common/uri';
import { PositronPlotCommProxy } from 'vs/workbench/services/languageRuntime/common/positronPlotCommProxy';
import { EditorCloseContext } from 'vs/workbench/common/editor';

/** The maximum number of recent executions to store. */
const MaxRecentExecutions = 10;
Expand Down Expand Up @@ -1051,8 +1052,11 @@ export class PositronPlotsService extends Disposable implements IPositronPlotsSe
});

this._editorService.onDidCloseEditor(editor => {
// Dispose the plot client for the editor when the editor matches the plot ID
// and the editor was closed, not moved or replaced.
if (editorPane?.getId() === editor.editor.editorId
&& editor.editor.resource?.path === plotId) {
&& editor.editor.resource?.path === plotId
&& editor.context === EditorCloseContext.UNKNOWN) {
const editorPlot = this._editorPlots.get(plotId);
if (editorPlot instanceof PlotClientInstance) {
this._editorPlots.delete(plotId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ export class PositronPlotsEditor extends EditorPane implements IPositronPlotsEdi

override dispose(): void {
this.disposeReactRenderer();
this._plotClient?.dispose();
super.dispose();
}
}
Expand Down

0 comments on commit b72be8f

Please sign in to comment.