From a5ab2536d95225aadbfa11bc2f66118fc95d995e Mon Sep 17 00:00:00 2001 From: Johannes Date: Fri, 26 May 2023 15:34:32 +0200 Subject: [PATCH] log when an editor action doesn't run because of enablement --- src/vs/editor/browser/editorExtensions.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/browser/editorExtensions.ts b/src/vs/editor/browser/editorExtensions.ts index 6536ffb9034..e793fe7a54b 100644 --- a/src/vs/editor/browser/editorExtensions.ts +++ b/src/vs/editor/browser/editorExtensions.ts @@ -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); }); }