fix(shortcuts): share one shortcut label formatter between settings and the session picker

This commit is contained in:
Chris Scott committed 2026-10-14 01:14:55 -04:00
1 parent 18102a3ce8
commit c41eff304c
5 files changed
+43 -19

No files matched your search

+10
View File
@@ -75,6 +75,16 @@ export function normalizeShortcut(shortcut: string): string {
return [...orderedModifiers, mainKey].join('+')
}
/**
* Formats a stored binding for display: empty keys render as an empty string, a direct binding as its normalized keys,
* and a leader binding as `leader → keys`, with both the leader and the keys normalized.
*/
export function formatShortcutLabel(keys: string, isDirect: boolean, leaderKey: string): string {
if (!keys) return ''
if (isDirect) return normalizeShortcut(keys)
return `${normalizeShortcut(leaderKey)} → ${normalizeShortcut(keys)}`
}
export function hasCommandModifier(shortcut: string): boolean {
return /(^|\+)(Ctrl|Cmd|Alt)\+./.test(shortcut)
}