@@ -40,8 +40,6 @@ export class BracketPairsTree extends Disposable {
40
40
private readonly denseKeyProvider = new DenseKeyProvider < string > ( ) ;
41
41
private readonly brackets = new LanguageAgnosticBracketTokens ( this . denseKeyProvider , this . getLanguageConfiguration ) ;
42
42
43
- private readonly parseQueue : TextEditInfo [ ] [ ] = [ ] ;
44
-
45
43
public didLanguageChange ( languageId : string ) : boolean {
46
44
return this . brackets . didLanguageChange ( languageId ) ;
47
45
}
@@ -92,7 +90,10 @@ export class BracketPairsTree extends Disposable {
92
90
toLength ( r . toLineNumber - r . fromLineNumber + 1 , 0 )
93
91
)
94
92
) ;
95
- this . queueParsing ( edits ) ;
93
+ this . astWithTokens = this . parseDocumentFromTextBuffer ( edits , this . astWithTokens , false ) ;
94
+ if ( ! this . initialAstWithoutTokens ) {
95
+ this . didChangeEmitter . fire ( ) ;
96
+ }
96
97
}
97
98
98
99
public handleContentChanged ( change : IModelContentChangedEvent ) {
@@ -104,23 +105,11 @@ export class BracketPairsTree extends Disposable {
104
105
lengthOfString ( c . text )
105
106
) ;
106
107
} ) . reverse ( ) ;
107
- this . queueParsing ( edits ) ;
108
- }
109
108
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 ) ;
122
112
}
123
- this . parseQueue . length = 0 ;
124
113
}
125
114
126
115
//#endregion
@@ -138,7 +127,6 @@ export class BracketPairsTree extends Disposable {
138
127
}
139
128
140
129
public getBracketsInRange ( range : Range ) : CallbackIterable < BracketInfo > {
141
- this . ensureState ( ) ;
142
130
const startOffset = toLength ( range . startLineNumber - 1 , range . startColumn - 1 ) ;
143
131
const endOffset = toLength ( range . endLineNumber - 1 , range . endColumn - 1 ) ;
144
132
return new CallbackIterable ( cb => {
@@ -148,7 +136,6 @@ export class BracketPairsTree extends Disposable {
148
136
}
149
137
150
138
public getBracketPairsInRange ( range : Range , includeMinIndentation : boolean ) : CallbackIterable < BracketPairWithMinIndentationInfo > {
151
- this . ensureState ( ) ;
152
139
const startLength = positionToLength ( range . getStartPosition ( ) ) ;
153
140
const endLength = positionToLength ( range . getEndPosition ( ) ) ;
154
141
@@ -160,13 +147,11 @@ export class BracketPairsTree extends Disposable {
160
147
}
161
148
162
149
public getFirstBracketAfter ( position : Position ) : IFoundBracket | null {
163
- this . ensureState ( ) ;
164
150
const node = this . initialAstWithoutTokens || this . astWithTokens ! ;
165
151
return getFirstBracketAfter ( node , lengthZero , node . length , positionToLength ( position ) ) ;
166
152
}
167
153
168
154
public getFirstBracketBefore ( position : Position ) : IFoundBracket | null {
169
- this . ensureState ( ) ;
170
155
const node = this . initialAstWithoutTokens || this . astWithTokens ! ;
171
156
return getFirstBracketBefore ( node , lengthZero , node . length , positionToLength ( position ) ) ;
172
157
}
0 commit comments