Fixes #117264: Abandon tokenizing a line after 500ms if possible.

This commit is contained in:
Alex Dima
2021-11-19 14:49:29 +01:00
parent 4970694100
commit a3f6aadf28
8 changed files with 32 additions and 18 deletions

View File

@@ -484,7 +484,13 @@ class TMTokenization extends Disposable {
}
public tokenize2(line: string, state: StackElement): TokenizationResult2 {
let textMateResult = this._grammar.tokenizeLine2(line, state);
const textMateResult = this._grammar.tokenizeLine2(line, state, 500);
if (textMateResult.stoppedEarly) {
console.warn(`Time limit reached when tokenizing line: ${line.substring(0, 100)}`);
// return the state at the beginning of the line
return new TokenizationResult2(textMateResult.tokens, state);
}
if (this._containsEmbeddedLanguages) {
let seenLanguages = this._seenLanguages;