@@ -33,12 +33,12 @@ function getOrCreateGrammarFactory (): CGTMGrammarFactory {
3333}
3434
3535const languageService = monaco . extra . StandaloneServices . get ( monaco . languages . ILanguageService )
36- async function createTextMateTokensProvider ( languageId : string ) : Promise < monaco . languages . ITokenizationSupport > {
36+ async function createTextMateTokensProvider ( languageId : string ) : Promise < monaco . languages . ITokenizationSupport | null > {
3737 const grammarFactory = getOrCreateGrammarFactory ( )
3838 const encodedLanguageId = languageService . languageIdCodec . encodeLanguageId ( languageId )
3939 const { grammar, initialState, containsEmbeddedLanguages } = await grammarFactory . createGrammar ( languageId , encodedLanguageId )
4040 if ( grammar == null ) {
41- throw new Error ( `No grammar found for language ${ languageId } ` )
41+ return null
4242 }
4343 const tokenization = new monaco . extra . TMTokenization ( grammar , initialState , containsEmbeddedLanguages )
4444 tokenization . onDidEncounterLanguage ( ( encodedLanguageId ) => {
@@ -48,9 +48,9 @@ async function createTextMateTokensProvider (languageId: string): Promise<monaco
4848 return new CGTMTokenizationSupport ( languageId , encodedLanguageId , tokenization , grammar )
4949}
5050
51- const tokenizationSupports = new Map < string , Promise < monaco . languages . ITokenizationSupport > > ( )
51+ const tokenizationSupports = new Map < string , Promise < monaco . languages . ITokenizationSupport | null > > ( )
5252
53- export function getOrCreateTextMateTokensProvider ( languageId : string ) : Promise < monaco . languages . ITokenizationSupport > {
53+ export function getOrCreateTextMateTokensProvider ( languageId : string ) : Promise < monaco . languages . ITokenizationSupport | null > {
5454 let tokenizationSupportPromise = tokenizationSupports . get ( languageId )
5555 if ( tokenizationSupportPromise == null ) {
5656 tokenizationSupportPromise = createTextMateTokensProvider ( languageId )
0 commit comments