Skip to content

Commit 604283b

Browse files
authored
Merge pull request microsoft#164571 from microsoft/tyriar/revert
Revert "Merge pull request microsoft#163958 from microsoft/tyriar/161622_brack…
2 parents ae45b3c + 9cf05e4 commit 604283b

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

src/vs/editor/common/model/bracketPairsTextModelPart/bracketPairsTree/bracketPairsTree.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ export class BracketPairsTree extends Disposable {
4040
private readonly denseKeyProvider = new DenseKeyProvider<string>();
4141
private readonly brackets = new LanguageAgnosticBracketTokens(this.denseKeyProvider, this.getLanguageConfiguration);
4242

43-
private readonly parseQueue: TextEditInfo[][] = [];
44-
4543
public didLanguageChange(languageId: string): boolean {
4644
return this.brackets.didLanguageChange(languageId);
4745
}
@@ -92,7 +90,10 @@ export class BracketPairsTree extends Disposable {
9290
toLength(r.toLineNumber - r.fromLineNumber + 1, 0)
9391
)
9492
);
95-
this.queueParsing(edits);
93+
this.astWithTokens = this.parseDocumentFromTextBuffer(edits, this.astWithTokens, false);
94+
if (!this.initialAstWithoutTokens) {
95+
this.didChangeEmitter.fire();
96+
}
9697
}
9798

9899
public handleContentChanged(change: IModelContentChangedEvent) {
@@ -104,23 +105,11 @@ export class BracketPairsTree extends Disposable {
104105
lengthOfString(c.text)
105106
);
106107
}).reverse();
107-
this.queueParsing(edits);
108-
}
109108

110-
private queueParsing(edits: TextEditInfo[]): void {
111-
// Queues parsing of the document so that it only runs before the state is actually
112-
// requested, this helps reduce editor input latency by doing parsing lazily instead of eagerly.
113-
this.parseQueue.push(edits);
114-
}
115-
116-
private ensureState() {
117-
for (const edits of this.parseQueue) {
118-
this.astWithTokens = this.parseDocumentFromTextBuffer(edits, this.astWithTokens, false);
119-
if (this.initialAstWithoutTokens) {
120-
this.initialAstWithoutTokens = this.parseDocumentFromTextBuffer(edits, this.initialAstWithoutTokens, false);
121-
}
109+
this.astWithTokens = this.parseDocumentFromTextBuffer(edits, this.astWithTokens, false);
110+
if (this.initialAstWithoutTokens) {
111+
this.initialAstWithoutTokens = this.parseDocumentFromTextBuffer(edits, this.initialAstWithoutTokens, false);
122112
}
123-
this.parseQueue.length = 0;
124113
}
125114

126115
//#endregion
@@ -138,7 +127,6 @@ export class BracketPairsTree extends Disposable {
138127
}
139128

140129
public getBracketsInRange(range: Range): CallbackIterable<BracketInfo> {
141-
this.ensureState();
142130
const startOffset = toLength(range.startLineNumber - 1, range.startColumn - 1);
143131
const endOffset = toLength(range.endLineNumber - 1, range.endColumn - 1);
144132
return new CallbackIterable(cb => {
@@ -148,7 +136,6 @@ export class BracketPairsTree extends Disposable {
148136
}
149137

150138
public getBracketPairsInRange(range: Range, includeMinIndentation: boolean): CallbackIterable<BracketPairWithMinIndentationInfo> {
151-
this.ensureState();
152139
const startLength = positionToLength(range.getStartPosition());
153140
const endLength = positionToLength(range.getEndPosition());
154141

@@ -160,13 +147,11 @@ export class BracketPairsTree extends Disposable {
160147
}
161148

162149
public getFirstBracketAfter(position: Position): IFoundBracket | null {
163-
this.ensureState();
164150
const node = this.initialAstWithoutTokens || this.astWithTokens!;
165151
return getFirstBracketAfter(node, lengthZero, node.length, positionToLength(position));
166152
}
167153

168154
public getFirstBracketBefore(position: Position): IFoundBracket | null {
169-
this.ensureState();
170155
const node = this.initialAstWithoutTokens || this.astWithTokens!;
171156
return getFirstBracketBefore(node, lengthZero, node.length, positionToLength(position));
172157
}

0 commit comments

Comments
 (0)