169
return token;
170
}
172
>
if (this.lineIdx > this.textBufferLineCount - 1 || (this.lineIdx === this.textBufferLineCount - 1 && this.lineCharOffset >= this.textBufferLastLineLength)) {
173
>
// We are after the end
174
>
return null;
175
>
}
176
>
177
>
if (this.line === null) {
178
>
this.lineTokens = this.textModel.tokenization.getLineTokens(this.lineIdx + 1);
179
>
this.line = this.lineTokens.getLineContent();
180
>
this.lineTokenOffset = this.lineCharOffset === 0 ? 0 : this.lineTokens.findTokenIndexAtOffset(this.lineCharOffset);
181
>
}
182
>
183
>
const startLineIdx = this.lineIdx;
184
>
const startLineCharOffset = this.lineCharOffset;
185
>
186
>
// limits the length of text tokens.
187
>
// If text tokens get too long, incremental updates will be slow
188
>
let lengthHeuristic = 0;
189
>
while (true) {
190
>
const lineTokens = this.lineTokens!;
191
>
const tokenCount = lineTokens.getCount();
192
>
193
>
let peekedBracketToken: Token | null = null;
194
>
195
>
if (this.lineTokenOffset < tokenCount) {
196
>
const tokenMetadata = lineTokens.getMetadata(this.lineTokenOffset);
197
>
while (this.lineTokenOffset + 1 < tokenCount && tokenMetadata === lineTokens.getMetadata(this.lineTokenOffset + 1)) {
198
// Skip tokens that are identical.
199
// Sometimes, (bracket) identifiers are split up into multiple tokens.
200
this.lineTokenOffset++;
201
}
203
>
const isOther = TokenMetadata.getTokenType(tokenMetadata) === StandardTokenType.Other;
204
>
const containsBracketType = TokenMetadata.containsBalancedBrackets(tokenMetadata);
205
>
206
>
const endOffset = lineTokens.getEndOffset(this.lineTokenOffset);
207
>
// Is there a bracket token next? Only consume text.
208
>
if (containsBracketType && isOther && this.lineCharOffset < endOffset) {
209
const languageId = lineTokens.getLanguageId(this.lineTokenOffset);
210
const text = this.line.substring(this.lineCharOffset, endOffset);