Skip to content

Commit 5a04a97

Browse files
committed
Log error for invalid TextMate grammar
1 parent 3a210cd commit 5a04a97

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/TextMate.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,13 @@ export async function tokenizeFile(document: vscode.TextDocument, runTwice?: boo
245245

246246
// const start = performance.now();
247247
activeScopeName = scopeName;
248-
const grammar = <IGrammar>await registry.loadGrammar(scopeName ?? '').catch(() => { });
248+
const grammar = <IGrammar>await registry.loadGrammar(scopeName ?? '').catch(error =>
249+
console.log("JSON TextMate: Invalid grammar for scopeName:", scopeName, '\n', error)
250+
);
249251
activeScopeName = null;
250252
if (!grammar) {
251253
vscode.window.showInformationMessage(`registered_languages:\n${JSON.stringify(grammarLanguages)}`);
252-
return grammar;
254+
return grammar; // yes `grammar` is `never` at this point
253255
}
254256
// vscode.window.showInformationMessage(`grammar ${performance.now() - start}ms`);
255257

0 commit comments

Comments
 (0)