Skip to content

Commit a5ab253

Browse files
committed
log when an editor action doesn't run because of enablement
1 parent 6924267 commit a5ab253

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/vs/editor/browser/editorExtensions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,13 @@ export abstract class EditorAction2 extends Action2 {
450450
// precondition does hold
451451
return editor.invokeWithinContext((editorAccessor) => {
452452
const kbService = editorAccessor.get(IContextKeyService);
453-
if (kbService.contextMatchesRules(withNullAsUndefined(this.desc.precondition))) {
454-
return this.runEditorCommand(editorAccessor, editor!, ...args);
453+
const logService = editorAccessor.get(ILogService);
454+
const enabled = kbService.contextMatchesRules(withNullAsUndefined(this.desc.precondition));
455+
if (!enabled) {
456+
logService.debug(`[EditorAction2] NOT running command because its precondition is FALSE`, this.desc.id, this.desc.precondition?.serialize());
457+
return;
455458
}
459+
return this.runEditorCommand(editorAccessor, editor!, ...args);
456460
});
457461
}
458462

0 commit comments

Comments
 (0)