inspectEditorToken: to work with no grammar

This commit is contained in:
Martin Aeschlimann
2020-01-17 15:49:08 +01:00
parent 2982c6296a
commit 5b96deebf4
2 changed files with 87 additions and 78 deletions

View File

@@ -322,8 +322,15 @@ export abstract class AbstractTextMateService extends Disposable implements ITex
}
public async createGrammar(modeId: string): Promise<IGrammar | null> {
const languageId = this._modeService.getLanguageIdentifier(modeId);
if (!languageId) {
return null;
}
const grammarFactory = await this._getOrCreateGrammarFactory();
const { grammar } = await grammarFactory.createGrammar(this._modeService.getLanguageIdentifier(modeId)!.id);
if (!grammarFactory.has(languageId.id)) {
return null;
}
const { grammar } = await grammarFactory.createGrammar(languageId.id);
return grammar;
}