From 7f7ccbe90fd6bba79c13408eba5b1af32a87b04b Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 21 Jun 2016 09:07:59 +0200 Subject: [PATCH] dedupe commands, last wins --- src/vs/platform/actions/common/commandsExtensionPoint.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vs/platform/actions/common/commandsExtensionPoint.ts b/src/vs/platform/actions/common/commandsExtensionPoint.ts index cfde60c4f6b..914aba05e64 100644 --- a/src/vs/platform/actions/common/commandsExtensionPoint.ts +++ b/src/vs/platform/actions/common/commandsExtensionPoint.ts @@ -7,12 +7,12 @@ import {localize} from 'vs/nls'; import {Action} from 'vs/base/common/actions'; import {join} from 'vs/base/common/paths'; +import {values} from 'vs/base/common/collections'; import {IJSONSchema} from 'vs/base/common/jsonSchema'; import {IExtensionService, IExtensionDescription} from 'vs/platform/extensions/common/extensions'; import {IKeybindingService, KbExpr} from 'vs/platform/keybinding/common/keybindingService'; import {IExtensionPointUser, ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry'; - export type Locations = 'editor/primary' | 'editor/secondary' | 'explorer/context'; export interface ThemableIcon { @@ -185,10 +185,13 @@ namespace schema { export const commands: ParsedCommand[] = []; +const _commandsById: { [id: string]: ParsedCommand } = Object.create(null); + function handleCommand(command: Command, user: IExtensionPointUser): void { if (validation.isValidCommand(command, user)) { // store command globally - commands.push(new ParsedCommand(command, user.description)); + const parsedCommand = new ParsedCommand(command, user.description); + _commandsById[parsedCommand.id] = parsedCommand; } } @@ -204,6 +207,7 @@ ExtensionsRegistry.registerExtensionPoint('commands', schem } } + commands.push(...values(_commandsById)); Object.freeze(commands); }); -- GitLab