mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
Use disposableStore
This commit is contained in:
parent
4a3ed6c71f
commit
a662ad1e98
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue