提交 a662ad1e 编写于 作者: M Matt Bierner

Use disposableStore

上级 4a3ed6c7
......@@ -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();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册