diff --git a/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts b/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts index 84d3d360e9a29..3b82abaf9bd32 100644 --- a/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts +++ b/packages/plugin-ext/src/main/browser/plugin-contribution-handler.ts @@ -165,6 +165,9 @@ export class PluginContributionHandler { indentationRules: this.convertIndentationRules(langConfiguration.indentationRules) })); } + pushContribution(`language.${lang.id}.activation`, + () => this.onDidActivateLanguage(lang.id, () => this.monacoTextmateService.activateLanguage(lang.id)) + ); } } @@ -197,10 +200,13 @@ export class PluginContributionHandler { getInjections: (scopeName: string) => this.injections.get(scopeName)! })); - - // load grammars on next tick to await registration of languages from all plugins in current tick - // see https://github.com/eclipse-theia/theia/issues/6907#issuecomment-578600243 - setTimeout(() => { + } + } + // load grammars on next tick to await registration of languages from all plugins in current tick + // see https://github.com/eclipse-theia/theia/issues/6907#issuecomment-578600243 + setTimeout(() => { + if (grammars && grammars.length) { + for (const grammar of grammars) { const language = grammar.language; if (language) { pushContribution(`grammar.language.${language}.scope`, () => this.grammarsRegistry.mapLanguageIdToTextmateGrammar(language, grammar.scope)); @@ -208,13 +214,16 @@ export class PluginContributionHandler { embeddedLanguages: this.convertEmbeddedLanguages(grammar.embeddedLanguages, logError), tokenTypes: this.convertTokenTypes(grammar.tokenTypes) })); - pushContribution(`grammar.language.${language}.activation`, - () => this.onDidActivateLanguage(language, () => this.monacoTextmateService.activateLanguage(language)) - ); } - }); + } } - } + if (languages && languages.length) { + for (const lang of languages) { + pushContribution(`language.${lang.id}.activation`, + () => this.onDidActivateLanguage(lang.id, () => this.monacoTextmateService.activateLanguage(lang.id))); + } + } + }); pushContribution('commands', () => this.registerCommands(contributions)); pushContribution('menus', () => this.menusContributionHandler.handle(contributions));