@@ -10,7 +10,7 @@ import { IContextViewService } from 'vs/platform/contextview/browser/contextView
1010import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
1111import { ICommandService , ICommandHandler } from 'vs/platform/commands/common/commands' ;
1212import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
13- import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
13+ import { ContextKeyExpr , IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
1414import { IEditorOptions , IActionDescriptor , ICodeEditorWidgetCreationOptions , IDiffEditorOptions , IModel , IModelChangedEvent , EventType } from 'vs/editor/common/editorCommon' ;
1515import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService' ;
1616import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService' ;
@@ -20,6 +20,7 @@ import { CodeEditor } from 'vs/editor/browser/codeEditor';
2020import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget' ;
2121import { ICodeEditor , IDiffEditor } from 'vs/editor/browser/editorBrowser' ;
2222import { IStandaloneColorService } from 'vs/editor/common/services/standaloneColorService' ;
23+ import { IOSupport } from 'vs/platform/keybinding/common/keybindingResolver' ;
2324
2425/**
2526 * The options to create an editor.
@@ -133,8 +134,8 @@ export class StandaloneEditor extends CodeEditor implements IStandaloneCodeEdito
133134 return null ;
134135 }
135136 let commandId = 'DYNAMIC_' + ( ++ LAST_GENERATED_COMMAND_ID ) ;
136-
137- this . _standaloneKeybindingService . addDynamicKeybinding ( commandId , keybinding , handler , context ) ;
137+ let whenExpression = IOSupport . readKeybindingWhen ( context ) ;
138+ this . _standaloneKeybindingService . addDynamicKeybinding ( commandId , keybinding , handler , whenExpression ) ;
138139 return commandId ;
139140 }
140141
@@ -157,9 +158,13 @@ export class StandaloneEditor extends CodeEditor implements IStandaloneCodeEdito
157158 let handler : ICommandHandler = ( accessor ) => {
158159 return this . trigger ( 'keyboard' , descriptor . id , null ) ;
159160 } ;
161+ let whenExpression = ContextKeyExpr . and (
162+ IOSupport . readKeybindingWhen ( descriptor . precondition ) ,
163+ IOSupport . readKeybindingWhen ( descriptor . keybindingContext ) ,
164+ ) ;
160165 toDispose = toDispose . concat (
161166 descriptor . keybindings . map ( ( kb ) => {
162- return this . _standaloneKeybindingService . addDynamicKeybinding ( addedAction . uniqueId , kb , handler , descriptor . keybindingContext ) ;
167+ return this . _standaloneKeybindingService . addDynamicKeybinding ( addedAction . uniqueId , kb , handler , whenExpression ) ;
163168 } )
164169 ) ;
165170 }
@@ -226,7 +231,8 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
226231 return null ;
227232 }
228233 let commandId = 'DYNAMIC_' + ( ++ LAST_GENERATED_COMMAND_ID ) ;
229- this . _standaloneKeybindingService . addDynamicKeybinding ( commandId , keybinding , handler , context ) ;
234+ let whenExpression = IOSupport . readKeybindingWhen ( context ) ;
235+ this . _standaloneKeybindingService . addDynamicKeybinding ( commandId , keybinding , handler , whenExpression ) ;
230236 return commandId ;
231237 }
232238
@@ -249,9 +255,13 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
249255 let handler : ICommandHandler = ( ctx ) => {
250256 return this . trigger ( 'keyboard' , descriptor . id , null ) ;
251257 } ;
258+ let whenExpression = ContextKeyExpr . and (
259+ IOSupport . readKeybindingWhen ( descriptor . precondition ) ,
260+ IOSupport . readKeybindingWhen ( descriptor . keybindingContext ) ,
261+ ) ;
252262 toDispose = toDispose . concat (
253263 descriptor . keybindings . map ( ( kb ) => {
254- return this . _standaloneKeybindingService . addDynamicKeybinding ( addedAction . uniqueId , kb , handler , descriptor . keybindingContext ) ;
264+ return this . _standaloneKeybindingService . addDynamicKeybinding ( addedAction . uniqueId , kb , handler , whenExpression ) ;
255265 } )
256266 ) ;
257267 }
0 commit comments