mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 21:23:07 +00:00
fix: handle undefined shortcuts in parseShortcut and formatShortcut
Add guards to handle undefined/null shortcuts for users with old persisted state missing the new terminal shortcuts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -48,7 +48,8 @@ export interface ShortcutKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper to parse shortcut string to ShortcutKey object
|
// Helper to parse shortcut string to ShortcutKey object
|
||||||
export function parseShortcut(shortcut: string): ShortcutKey {
|
export function parseShortcut(shortcut: string | undefined | null): ShortcutKey {
|
||||||
|
if (!shortcut) return { key: "" };
|
||||||
const parts = shortcut.split("+").map((p) => p.trim());
|
const parts = shortcut.split("+").map((p) => p.trim());
|
||||||
const result: ShortcutKey = { key: parts[parts.length - 1] };
|
const result: ShortcutKey = { key: parts[parts.length - 1] };
|
||||||
|
|
||||||
@@ -80,7 +81,8 @@ export function parseShortcut(shortcut: string): ShortcutKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper to format ShortcutKey to display string
|
// Helper to format ShortcutKey to display string
|
||||||
export function formatShortcut(shortcut: string, forDisplay = false): string {
|
export function formatShortcut(shortcut: string | undefined | null, forDisplay = false): string {
|
||||||
|
if (!shortcut) return "";
|
||||||
const parsed = parseShortcut(shortcut);
|
const parsed = parseShortcut(shortcut);
|
||||||
const parts: string[] = [];
|
const parts: string[] = [];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user