fix(keyboard): support CJK input methods for custom shortcuts
Summary
Keyboard shortcuts handled through handleCustomShortcut (not registered as SwiftUI menu items) fail when a CJK input method (Korean, Japanese, Chinese) is active. For example, Cmd+T (New Terminal) and Cmd+Shift+L (Open Browser) do not work with Korean 2-Set IME, while menu-registered shortcuts like Cmd+B (Toggle Sidebar) and Cmd+D (Split Right) work fine because AppKit's menu system processes them before the IME.
Root cause: When a CJK IME is active, event.charactersIgnoringModifiers returns non-ASCII characters (e.g. "ㅅ" for the T key). Two gates in matchShortcut treat these non-ASCII characters as valid character data and block the ANSI keyCode fallback path:
- The strict character-match gate returns
falseearly for letter-based Command shortcuts when characters are present but don't match - The ANSI keyCode fallback condition requires both event characters and layout characters to be absent, but Korean characters are non-empty
Fix: Treat non-ASCII characters from CJK input methods as absent for shortcut matching purposes — they cannot match ASCII shortcut keys, so the function falls through to keyCode-based matching which correctly identifies the physical key.
Test plan
- Manually verified: Cmd+T creates new terminal with Korean 2-Set IME active
- Manually verified: Cmd+Shift+L opens browser with Korean 2-Set IME active
- Manually verified: Both shortcuts still work with English input source
- Manually verified: Menu-registered shortcuts (Cmd+B, Cmd+D) unaffected
- Added unit tests simulating Korean IME events for Cmd+T and Cmd+Shift+L
- CI: existing shortcut routing tests pass
Fixes #1545
Summary by cubic
Fixes custom keyboard shortcuts failing when a CJK IME is active by ignoring non-ASCII IME characters and falling back to ANSI keyCode matching. Restores shortcuts like Cmd+T and Cmd+Shift+L under Korean/Japanese/Chinese IMEs without affecting menu-registered shortcuts.
- Bug Fixes
- Only treat
charactersIgnoringModifiersand layout characters as usable when they are ASCII; otherwise match by physicalkeyCode. - Added tests simulating Korean IME for Cmd+T and Cmd+Shift+L; existing shortcut routing tests continue to pass.
- Only treat