Skip to content

Commit

Permalink
[vscode] fix eclipse-theia#7111: activate by language based on create…
Browse files Browse the repository at this point in the history
…d mode

Signed-off-by: Anton Kosyakov <[email protected]>
  • Loading branch information
akosyakov committed Feb 24, 2020
1 parent 56bff8a commit a1397b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
7 changes: 7 additions & 0 deletions packages/monaco/src/typings/monaco/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,15 @@ declare module monaco.services {
readonly language: string;
}

export interface IMode {
getId(): string;
getLanguageIdentifier(): LanguageIdentifier;
}

// https://github.com/TypeFox/vscode/blob/70b8db24a37fafc77247de7f7cb5bb0195120ed0/src/vs/editor/common/services/modeService.ts#L30
export interface IModeService {
private readonly _instantiatedModes: { [modeId: string]: IMode; };
readonly onDidCreateMode: monaco.IEvent<IMode>;
createByFilepathOrFirstLine(rsource: monaco.Uri | null, firstLine?: string): ILanguageSelection;
getLanguageIdentifier(modeId: string): LanguageIdentifier | null;
}
Expand Down
12 changes: 5 additions & 7 deletions packages/plugin-ext/src/hosted/browser/hosted-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { MainPluginApiProvider } from '../../common/plugin-ext-api-contribution'
import { PluginPathsService } from '../../main/common/plugin-paths-protocol';
import { getPreferences } from '../../main/browser/preference-registry-main';
import { PluginServer } from '../../common/plugin-protocol';
import { MonacoTextmateService } from '@theia/monaco/lib/browser/textmate';
import { Deferred } from '@theia/core/lib/common/promise-util';
import { DebugSessionManager } from '@theia/debug/lib/browser/debug-session-manager';
import { DebugConfigurationManager } from '@theia/debug/lib/browser/debug-configuration-manager';
Expand Down Expand Up @@ -101,9 +100,6 @@ export class HostedPluginSupport {
@inject(WorkspaceService)
protected readonly workspaceService: WorkspaceService;

@inject(MonacoTextmateService)
protected readonly monacoTextmateService: MonacoTextmateService;

@inject(CommandRegistry)
protected readonly commands: CommandRegistry;

Expand Down Expand Up @@ -156,10 +152,12 @@ export class HostedPluginSupport {
this.theiaReadyPromise = Promise.all([this.preferenceServiceImpl.ready, this.workspaceService.roots]);
this.workspaceService.onWorkspaceChanged(() => this.updateStoragePath());

for (const id of this.monacoTextmateService.activatedLanguages) {
this.activateByLanguage(id);
const modeService = monaco.services.StaticServices.modeService.get();
for (const modeId of Object.keys(modeService['_instantiatedModes'])) {
const mode = modeService['_instantiatedModes'][modeId];
this.activateByLanguage(mode.getId());
}
this.monacoTextmateService.onDidActivateLanguage(id => this.activateByLanguage(id));
modeService.onDidCreateMode(mode => this.activateByLanguage(mode.getId()));
this.commands.onWillExecuteCommand(event => this.ensureCommandHandlerRegistration(event));
this.debugSessionManager.onWillStartDebugSession(event => this.ensureDebugActivation(event));
this.debugSessionManager.onWillResolveDebugConfiguration(event => this.ensureDebugActivation(event, 'onDebugResolve', event.debugType));
Expand Down

0 comments on commit a1397b3

Please sign in to comment.