log when an editor action doesn't run because of enablement

This commit is contained in:
Johannes 2023-05-26 15:34:32 +02:00
parent 6924267d84
commit a5ab2536d9
No known key found for this signature in database
GPG key ID: 6DEF802A22264FCA

View file

@ -450,9 +450,13 @@ export abstract class EditorAction2 extends Action2 {
// precondition does hold
return editor.invokeWithinContext((editorAccessor) => {
const kbService = editorAccessor.get(IContextKeyService);
if (kbService.contextMatchesRules(withNullAsUndefined(this.desc.precondition))) {
return this.runEditorCommand(editorAccessor, editor!, ...args);
const logService = editorAccessor.get(ILogService);
const enabled = kbService.contextMatchesRules(withNullAsUndefined(this.desc.precondition));
if (!enabled) {
logService.debug(`[EditorAction2] NOT running command because its precondition is FALSE`, this.desc.id, this.desc.precondition?.serialize());
return;
}
return this.runEditorCommand(editorAccessor, editor!, ...args);
});
}