Fix terminal zoom on non-US ISO keyboard layouts
Summary
On Swedish (and other non-US ISO) layouts, pressing ⌘+ in a focused terminal pane fires zoom-out instead of zoom-in. The + key on Swedish sits at the physical position of US - (keyCode 27), so US-keycode-based matchers route the keystroke to the wrong action.
This PR fixes it at three layers:
-
AppDelegate.swift— main fix. When a zoom shortcut is detected and the terminal owns first responder, cmux was forwarding the rawNSEventto Ghostty. Ghostty's internal keybind matcher then resolved the event by US-layout keycode, mis-firing decrease_font_size on Swedish ⌘+. Instead, dispatch the action by name viaghostty_surface_binding_actionusing the result of the already-layout-awarebrowserZoomShortcutActionhelper. -
KeyboardShortcutSettings.swift—matches. The ANSI-keycode fallback fired unconditionally for symbol command shortcuts, masking the typed ASCII character even when it clearly didn't match the bound shortcut key. Letter shortcuts already required a character match in that case; symbol shortcuts now do too. Non-Latin layouts still fall back to US keycodes (hasEventChars && !eventCharsAreASCII) so ⌘W remains reachable on Cyrillic/etc. -
KeyboardShortcutSettings.swift—normalizedShortcutEventCharacter."+"→"="and"_"→"-"were gated onapplyShiftSymbolNormalization. On Swedish (and similar ISO layouts)+is typed without shift, so the gate left the typed"+"un-mapped and Cmd++could not match the zoom-in binding stored as"=". These two mappings are now unconditional; nothing binds to literal+/_so there is no conflict.
Test plan
- New
KeyboardShortcutLayoutTests(9 tests, all passing):- Swedish ⌘+ matches
.browserZoomInand does not match.browserZoomOut - Swedish ⌘_ maps to
.browserZoomOut - US ⌘=, ⌘⇧= (typed as
+), ⌘− baselines preserved - Russian ⌘W still resolves via US-keycode fallback (non-ASCII typed char)
- Anti-regression: an unrelated ASCII char at the same physical position does not match through the keycode fallback
- Swedish ⌘+ matches
- Manual test on a Swedish ISO keyboard:
- ⌘+ in a terminal pane zooms in
- ⌘− zooms out
- ⌘0 resets
🤖 Generated with Claude Code
Summary by cubic
Fixes terminal zoom shortcuts on non‑US ISO layouts (e.g., Swedish). Cmd + now zooms in (not out) when a terminal pane is focused.
- Bug Fixes
- Route zoom shortcuts to Ghostty by action name using the layout‑aware
browserZoomShortcutAction, instead of forwarding rawNSEvent. - Require a character match for Command symbol shortcuts before falling back to US ANSI keycodes; non‑Latin layouts still use the fallback.
- Normalize "+"→"=" and "_"→"-" unconditionally so stored zoom bindings match on layouts where "+" is unshifted.
- Added
KeyboardShortcutLayoutTestscovering Swedish ⌘+, US baselines, and Russian ⌘W.
- Route zoom shortcuts to Ghostty by action name using the layout‑aware
Summary by CodeRabbit
- Bug Fixes
- Improved keyboard shortcut detection across international keyboard layouts (Swedish, Russian, etc.)
- Fixed font zoom keyboard shortcuts in the terminal to function correctly across different layouts
- Enhanced keyboard event matching to ensure shortcuts work reliably regardless of physical keyboard configuration