From b4ae810c84bb61ae278751d29ea44fe86e776bb6 Mon Sep 17 00:00:00 2001 From: John Morabito Date: Sat, 13 Jun 2026 11:37:39 -0400 Subject: [PATCH] fix: macro icons now display correctly in all UI contexts Set icon directly on addCommand so it appears in the command palette, status bar, and mobile toolbar. Also fixes removeCommand referencing bare `app` instead of `plugin.app`, and replaces Array.remove() during forEach iteration (mutation hazard) with a filter in injectIcons. Fixes #149 (cherry-picked from PR by Anton/Lyqed) Co-Authored-By: Claude Sonnet 4.6 --- src/util.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/util.tsx b/src/util.tsx index 367487d..ac0eb5c 100644 --- a/src/util.tsx +++ b/src/util.tsx @@ -144,16 +144,17 @@ export function updateMacroCommands(plugin: CommanderPlugin): void { ); for (const command of oldCommands) { //@ts-ignore - app.commands.removeCommand(command); + plugin.app.commands.removeCommand(command); } const macros = plugin.settings.macros; - for (const [idx, macro] of Object.entries(macros)) { + for (const [idx, macro] of macros.entries()) { plugin.addCommand({ id: `macro-${idx}`, name: macro.name, + icon: macro.icon, callback: () => { - plugin.executeMacro(parseInt(idx)); + plugin.executeMacro(Number(idx)); }, }); } @@ -195,7 +196,7 @@ export function injectIcons( if (command) { command.icon = mapped.iconID; } else { - settings.mappedIcons.remove(mapped); + settings.mappedIcons = settings.mappedIcons.filter(m => m !== mapped); } }); }