提交 04dd8758 编写于 作者: B Benjamin Pasero

debt - fix listener leak in file editor

上级 48d48a03
......@@ -118,6 +118,7 @@ export abstract class BaseEditor extends Panel implements IEditor {
setVisible(visible: boolean, group?: IEditorGroup): void {
super.setVisible(visible);
// Propagate to Editor
this.setEditorVisible(visible, group);
}
......
......@@ -30,6 +30,7 @@ import { IEditorGroupsService, IEditorGroup } from 'vs/workbench/services/group/
import { CancellationToken } from 'vs/base/common/cancellation';
import { IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
import { createErrorWithActions } from 'vs/base/common/errorsWithActions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
/**
* An implementation of editor for file system resources.
......@@ -39,6 +40,7 @@ export class TextFileEditor extends BaseTextEditor {
static readonly ID = TEXT_FILE_EDITOR_ID;
private restoreViewState: boolean;
private groupListener: IDisposable;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
......@@ -96,7 +98,8 @@ export class TextFileEditor extends BaseTextEditor {
// React to editors closing to preserve or clear view state. This needs to happen
// in the onWillCloseEditor because at that time the editor has not yet
// been disposed and we can safely persist the view state still as needed.
this._register((group as IEditorGroupView).onWillCloseEditor(e => {
this.groupListener = dispose(this.groupListener);
this.groupListener = ((group as IEditorGroupView).onWillCloseEditor(e => {
if (e.editor === this.input) {
this.doSaveOrClearTextEditorViewState(this.input);
}
......@@ -276,4 +279,10 @@ export class TextFileEditor extends BaseTextEditor {
this.saveTextEditorViewState(input.getResource());
}
}
dispose(): void {
this.groupListener = dispose(this.groupListener);
super.dispose();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册