Skip to content

Commit 91e6ae9

Browse files
authored
Fix toggle line comment for tree-sitter (#244115)
1 parent 7249efc commit 91e6ae9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class TreeSitterTokenizationSupport extends Disposable implements ITreeSi
128128
private _colorThemeData!: ColorThemeData;
129129
private _languageAddedListener: IDisposable | undefined;
130130
private _codeEditors: TreeSitterCodeEditors;
131-
private _encodedLanguageId: LanguageId;
131+
private _encodedLanguage: LanguageId | undefined;
132132

133133
constructor(
134134
private readonly _queries: TreeSitterQueries,
@@ -142,7 +142,6 @@ export class TreeSitterTokenizationSupport extends Disposable implements ITreeSi
142142
@IInstantiationService private readonly _instantiationService: IInstantiationService,
143143
) {
144144
super();
145-
this._encodedLanguageId = this._languageIdCodec.encodeLanguageId(this._languageId);
146145
this._codeEditors = this._instantiationService.createInstance(TreeSitterCodeEditors, this._languageId);
147146
this._register(this._codeEditors.onDidChangeViewport(e => {
148147
this._parseAndTokenizeViewPort(e.model, e.ranges);
@@ -180,6 +179,13 @@ export class TreeSitterTokenizationSupport extends Disposable implements ITreeSi
180179
}));
181180
}
182181

182+
private get _encodedLanguageId(): LanguageId {
183+
if (!this._encodedLanguage) {
184+
this._encodedLanguage = this._languageIdCodec.encodeLanguageId(this._languageId);
185+
}
186+
return this._encodedLanguage;
187+
}
188+
183189
private _setInitialTokens(textModel: ITextModel) {
184190
const tokens: TokenUpdate[] = this._createEmptyTokens(textModel);
185191
this._tokenizationStoreService.setTokens(textModel, tokens, TokenQuality.None);

0 commit comments

Comments
 (0)