Skip to content

Commit 8c6a304

Browse files
committed
1 parent ca3dd8c commit 8c6a304

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
241241
private _beginCompute(position: Position): void {
242242
const grammar = this._textMateService.createTokenizer(this._model.getLanguageId());
243243
const semanticTokens = this._computeSemanticTokens(position);
244-
const treeSitterTree = ((this._model.tokenization as TokenizationTextModelPart).tokens.get() as TreeSitterSyntaxTokenBackend).tree.get();
244+
const backend = (this._model.tokenization as TokenizationTextModelPart).tokens.get();
245+
const asTreeSitterBackend = backend instanceof TreeSitterSyntaxTokenBackend ? backend : undefined;
245246

246247
dom.clearNode(this._domNode);
247248
this._domNode.appendChild(document.createTextNode(nls.localize('inspectTMScopesWidget.loading', "Loading...")));
@@ -250,6 +251,7 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
250251
if (this._isDisposed) {
251252
return;
252253
}
254+
const treeSitterTree = asTreeSitterBackend?.tree.get();
253255
this._compute(grammar, semanticTokens, treeSitterTree, position);
254256
this._domNode.style.maxWidth = `${Math.max(this._editor.getLayoutInfo().width * 0.66, 500)}px`;
255257
this._editor.layoutContentWidget(this);

0 commit comments

Comments
 (0)