From d06956dd6321636f7b86247031b814854d1b1941 Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 12 Feb 2016 16:08:26 +0100 Subject: [PATCH] editor: allow editor action descriptor to pass in a KbExpr --- src/vs/editor/common/editorCommonExtensions.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/vs/editor/common/editorCommonExtensions.ts b/src/vs/editor/common/editorCommonExtensions.ts index 00fee376261..c11fba2006f 100644 --- a/src/vs/editor/common/editorCommonExtensions.ts +++ b/src/vs/editor/common/editorCommonExtensions.ts @@ -27,6 +27,7 @@ export enum ContextKey { export interface IEditorActionKeybindingOptions extends IKeybindings { handler?: ICommandHandler; context: ContextKey; + kbExpr?: KbExpr; } export interface IEditorCommandKeybindingOptions extends IKeybindings { context: ContextKey; @@ -177,10 +178,14 @@ class EditorContributionRegistry { } var context: KbExpr = null; - if (desc.kbOpts.context === ContextKey.EditorTextFocus) { - context = KbExpr.has(EditorCommon.KEYBINDING_CONTEXT_EDITOR_TEXT_FOCUS); - } else if (desc.kbOpts.context === ContextKey.EditorFocus) { - context = KbExpr.has(EditorCommon.KEYBINDING_CONTEXT_EDITOR_FOCUS); + if (typeof desc.kbOpts.kbExpr === 'undefined') { + if (desc.kbOpts.context === ContextKey.EditorTextFocus) { + context = KbExpr.has(EditorCommon.KEYBINDING_CONTEXT_EDITOR_TEXT_FOCUS); + } else if (desc.kbOpts.context === ContextKey.EditorFocus) { + context = KbExpr.has(EditorCommon.KEYBINDING_CONTEXT_EDITOR_FOCUS); + } + } else { + context = desc.kbOpts.kbExpr; } var commandDesc: ICommandDescriptor = { -- GitLab