Fixes #132802 by making maxTokenizationLineLength configurable per language and reducing the default for TypeScript.

This commit is contained in:
Henning Dieterichs 2021-10-13 16:19:54 +02:00
parent 077c5749d2
commit 1a2749d798
No known key found for this signature in database
GPG key ID: 771381EFFDB9EC06
2 changed files with 14 additions and 5 deletions

View file

@ -13,6 +13,11 @@
"update-grammar": "node ./build/update-grammars.js"
},
"contributes": {
"configurationDefaults": {
"[typescript]": {
"editor.maxTokenizationLineLength": 2500
}
},
"languages": [
{
"id": "typescript",

View file

@ -280,7 +280,7 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
this._onDidEncounterLanguage.fire(languageId);
}
});
return new TMTokenizationSupport(r.languageId, tokenization, this._configurationService);
return new TMTokenizationSupport(languageIdentifier, tokenization, this._configurationService);
} catch (err) {
onUnexpectedError(err);
return null;
@ -418,16 +418,20 @@ class TMTokenizationSupport implements ITokenizationSupport {
private _maxTokenizationLineLength: number;
constructor(
languageId: LanguageId,
languageId: LanguageIdentifier,
actual: TMTokenization,
@IConfigurationService private readonly _configurationService: IConfigurationService,
) {
this._languageId = languageId;
this._languageId = languageId.id;
this._actual = actual;
this._maxTokenizationLineLength = this._configurationService.getValue<number>('editor.maxTokenizationLineLength');
this._maxTokenizationLineLength = this._configurationService.getValue<number>('editor.maxTokenizationLineLength', {
overrideIdentifier: languageId.language
});
this._configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('editor.maxTokenizationLineLength')) {
this._maxTokenizationLineLength = this._configurationService.getValue<number>('editor.maxTokenizationLineLength');
this._maxTokenizationLineLength = this._configurationService.getValue<number>('editor.maxTokenizationLineLength', {
overrideIdentifier: languageId.language
});
}
});
}