Skip to content

Commit

Permalink
Update bracket decorations asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jan 11, 2017
1 parent 7d0986b commit a431cda
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { Disposable } from 'vs/base/common/lifecycle';
import { Range } from 'vs/editor/common/core/range';
import { Position } from 'vs/editor/common/core/position';
import { RunOnceScheduler } from 'vs/base/common/async';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { editorAction, commonEditorContribution, ServicesAccessor, EditorAction } from 'vs/editor/common/editorCommonExtensions';

Expand Down Expand Up @@ -64,17 +65,19 @@ export class BracketMatchingController extends Disposable implements editorCommo
private _lastBracketsData: BracketsData[];
private _lastVersionId: number;
private _decorations: string[];
private _updateBracketsSoon: RunOnceScheduler;

constructor(editor: editorCommon.ICommonCodeEditor) {
super();
this._editor = editor;
this._lastBracketsData = [];
this._lastVersionId = 0;
this._decorations = [];
this._updateBracketsSoon = this._register(new RunOnceScheduler(() => this._updateBrackets(), 50));

this._updateBrackets();
this._register(editor.onDidChangeCursorPosition((e) => this._updateBrackets()));
this._register(editor.onDidChangeModel((e) => { this._decorations = []; this._updateBrackets(); }));
this._updateBracketsSoon.schedule();
this._register(editor.onDidChangeCursorPosition((e) => this._updateBracketsSoon.schedule()));
this._register(editor.onDidChangeModel((e) => { this._decorations = []; this._updateBracketsSoon.schedule(); }));
}

public getId(): string {
Expand Down

0 comments on commit a431cda

Please sign in to comment.