From 1ba1d4ce4342169dfadf2e00a88e1656ee3168db Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Thu, 16 Jul 2020 15:41:24 +0200 Subject: [PATCH] Made menu and keybinding contributions extensible From now on, downstream project can subclass and rebind various menu and keybinding contributions to overcome a Theia limitation. See: eclipse-theia/theia#8175 Signed-off-by: Akos Kitta --- packages/editor/src/browser/editor-frontend-module.ts | 3 ++- packages/monaco/src/browser/monaco-frontend-module.ts | 6 ++++-- packages/workspace/src/browser/workspace-frontend-module.ts | 6 ++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/editor/src/browser/editor-frontend-module.ts b/packages/editor/src/browser/editor-frontend-module.ts index 4aa2ce06f3628..5a9efd368cd2e 100644 --- a/packages/editor/src/browser/editor-frontend-module.ts +++ b/packages/editor/src/browser/editor-frontend-module.ts @@ -55,7 +55,8 @@ export default new ContainerModule(bind => { bind(KeybindingContext).toService(StrictEditorTextFocusContext); bind(KeybindingContext).to(EditorTextFocusContext).inSingletonScope(); bind(KeybindingContext).to(DiffEditorTextFocusContext).inSingletonScope(); - bind(KeybindingContribution).to(EditorKeybindingContribution).inSingletonScope(); + bind(EditorKeybindingContribution).toSelf().inSingletonScope(); + bind(KeybindingContribution).toService(EditorKeybindingContribution); bind(EditorContribution).toSelf().inSingletonScope(); bind(FrontendApplicationContribution).toService(EditorContribution); diff --git a/packages/monaco/src/browser/monaco-frontend-module.ts b/packages/monaco/src/browser/monaco-frontend-module.ts index 9b7586213d5cd..0134853e88987 100644 --- a/packages/monaco/src/browser/monaco-frontend-module.ts +++ b/packages/monaco/src/browser/monaco-frontend-module.ts @@ -122,8 +122,10 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => { bind(MonacoCommandRegistry).toSelf().inSingletonScope(); bind(CommandContribution).to(MonacoEditorCommandHandlers).inSingletonScope(); - bind(MenuContribution).to(MonacoEditorMenuContribution).inSingletonScope(); - bind(KeybindingContribution).to(MonacoKeybindingContribution).inSingletonScope(); + bind(MonacoEditorMenuContribution).toSelf().inSingletonScope(); + bind(MenuContribution).toService(MonacoEditorMenuContribution); + bind(MonacoKeybindingContribution).toSelf().inSingletonScope(); + bind(KeybindingContribution).toService(MonacoKeybindingContribution); rebind(StrictEditorTextFocusContext).to(MonacoStrictEditorTextFocusContext).inSingletonScope(); bind(MonacoQuickOpenService).toSelf().inSingletonScope(); diff --git a/packages/workspace/src/browser/workspace-frontend-module.ts b/packages/workspace/src/browser/workspace-frontend-module.ts index 2300d21aa2ef0..2a5fe1f8b399f 100644 --- a/packages/workspace/src/browser/workspace-frontend-module.ts +++ b/packages/workspace/src/browser/workspace-frontend-module.ts @@ -72,8 +72,10 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un bind(WorkspaceCommandContribution).toSelf().inSingletonScope(); bind(CommandContribution).toService(WorkspaceCommandContribution); - bind(MenuContribution).to(FileMenuContribution).inSingletonScope(); - bind(MenuContribution).to(EditMenuContribution).inSingletonScope(); + bind(FileMenuContribution).toSelf().inSingletonScope(); + bind(MenuContribution).toService(FileMenuContribution); + bind(EditMenuContribution).toSelf().inSingletonScope(); + bind(MenuContribution).toService(EditMenuContribution); bind(WorkspaceDeleteHandler).toSelf().inSingletonScope(); bind(WorkspaceDuplicateHandler).toSelf().inSingletonScope(); bind(WorkspaceCompareHandler).toSelf().inSingletonScope();