Skip to content

Commit 4cb80de

Browse files
committed
Fixes microsoft#61912: Account for the fact that modes can be instantiated before all extension points have been handled.
1 parent 98fbaad commit 4cb80de

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/vs/workbench/parts/codeEditor/electron-browser/languageConfiguration/languageConfigurationExtensionPoint.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
1515
import { IFileService } from 'vs/platform/files/common/files';
1616
import { Extensions, IJSONContributionRegistry } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
1717
import { Registry } from 'vs/platform/registry/common/platform';
18+
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
1819
import { ITextMateService } from 'vs/workbench/services/textMate/electron-browser/textMateService';
1920

2021
interface IRegExp {
@@ -67,12 +68,19 @@ export class LanguageConfigurationFileHandler {
6768
constructor(
6869
@ITextMateService textMateService: ITextMateService,
6970
@IModeService private readonly _modeService: IModeService,
70-
@IFileService private readonly _fileService: IFileService
71+
@IFileService private readonly _fileService: IFileService,
72+
@IExtensionService private readonly _extensionService: IExtensionService
7173
) {
7274
this._done = [];
7375

7476
// Listen for hints that a language configuration is needed/usefull and then load it once
75-
this._modeService.onDidCreateMode((mode) => this._loadConfigurationsForMode(mode.getLanguageIdentifier()));
77+
this._modeService.onDidCreateMode((mode) => {
78+
const languageIdentifier = mode.getLanguageIdentifier();
79+
// Modes can be instantiated before the extension points have finished registering
80+
this._extensionService.whenInstalledExtensionsRegistered().then(() => {
81+
this._loadConfigurationsForMode(languageIdentifier);
82+
});
83+
});
7684
textMateService.onDidEncounterLanguage((languageId) => {
7785
this._loadConfigurationsForMode(this._modeService.getLanguageIdentifier(languageId));
7886
});

src/vs/workbench/services/textMate/electron-browser/TMSyntax.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
2020
import { IFileService } from 'vs/platform/files/common/files';
2121
import { ILogService } from 'vs/platform/log/common/log';
2222
import { INotificationService } from 'vs/platform/notification/common/notification';
23+
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
2324
import { ExtensionMessageCollector } from 'vs/workbench/services/extensions/common/extensionsRegistry';
2425
import { IEmbeddedLanguagesMap, ITMSyntaxExtensionPoint, TokenTypesContribution, grammarsExtPoint } from 'vs/workbench/services/textMate/electron-browser/TMGrammars';
2526
import { ITextMateService } from 'vs/workbench/services/textMate/electron-browser/textMateService';
@@ -157,7 +158,8 @@ export class TextMateService implements ITextMateService {
157158
@IWorkbenchThemeService themeService: IWorkbenchThemeService,
158159
@IFileService fileService: IFileService,
159160
@INotificationService notificationService: INotificationService,
160-
@ILogService logService: ILogService
161+
@ILogService logService: ILogService,
162+
@IExtensionService extensionService: IExtensionService
161163
) {
162164
this._styleElement = dom.createStyleSheet();
163165
this._styleElement.className = 'vscode-tokens-styles';
@@ -202,9 +204,12 @@ export class TextMateService implements ITextMateService {
202204

203205
this._modeService.onDidCreateMode((mode) => {
204206
let modeId = mode.getId();
205-
if (this._languageToScope.has(modeId)) {
206-
this.registerDefinition(modeId);
207-
}
207+
// Modes can be instantiated before the extension points have finished registering
208+
extensionService.whenInstalledExtensionsRegistered().then(() => {
209+
if (this._languageToScope.has(modeId)) {
210+
this.registerDefinition(modeId);
211+
}
212+
});
208213
});
209214
}
210215

0 commit comments

Comments
 (0)