diff --git a/src/vs/editor/browser/core/editorState.ts b/src/vs/editor/browser/core/editorState.ts index e674795c4c17479dff50d02e707b43b8acb3872b..9b244cd770f7218768abf3a8400eb7ee67afe976 100644 --- a/src/vs/editor/browser/core/editorState.ts +++ b/src/vs/editor/browser/core/editorState.ts @@ -8,7 +8,7 @@ import { ICodeEditor, IActiveCodeEditor } from 'vs/editor/browser/editorBrowser' import { Position } from 'vs/editor/common/core/position'; import { Range } from 'vs/editor/common/core/range'; import { CancellationTokenSource, CancellationToken } from 'vs/base/common/cancellation'; -import { IDisposable, dispose } from 'vs/base/common/lifecycle'; +import { IDisposable, DisposableStore } from 'vs/base/common/lifecycle'; import { ITextModel } from 'vs/editor/common/model'; import { EditorKeybindingCancellationTokenSource } from 'vs/editor/browser/core/keybindingCancellation'; @@ -81,28 +81,28 @@ export class EditorState { */ export class EditorStateCancellationTokenSource extends EditorKeybindingCancellationTokenSource implements IDisposable { - private readonly _listener: IDisposable[] = []; + private readonly _listener = new DisposableStore(); constructor(readonly editor: IActiveCodeEditor, flags: CodeEditorStateFlag, parent?: CancellationToken) { super(editor, parent); if (flags & CodeEditorStateFlag.Position) { - this._listener.push(editor.onDidChangeCursorPosition(_ => this.cancel())); + this._listener.add(editor.onDidChangeCursorPosition(_ => this.cancel())); } if (flags & CodeEditorStateFlag.Selection) { - this._listener.push(editor.onDidChangeCursorSelection(_ => this.cancel())); + this._listener.add(editor.onDidChangeCursorSelection(_ => this.cancel())); } if (flags & CodeEditorStateFlag.Scroll) { - this._listener.push(editor.onDidScrollChange(_ => this.cancel())); + this._listener.add(editor.onDidScrollChange(_ => this.cancel())); } if (flags & CodeEditorStateFlag.Value) { - this._listener.push(editor.onDidChangeModel(_ => this.cancel())); - this._listener.push(editor.onDidChangeModelContent(_ => this.cancel())); + this._listener.add(editor.onDidChangeModel(_ => this.cancel())); + this._listener.add(editor.onDidChangeModelContent(_ => this.cancel())); } } dispose() { - dispose(this._listener); + this._listener.dispose(); super.dispose(); } }