mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix(shortcuts): share one shortcut label formatter between settings and the session picker
This commit is contained in:
1 parent
18102a3ce8
commit
c41eff304c
5 files changed
+43
-19
No files matched your search
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user