mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
macOS: fix upper cased letter is not correctly mapped to menu shortcut (#12039)
This is known issues before key-related PRs, tested on
fa9265636b.
The following config is mapped incorrectly to the menu shortcut:
```
keybind=A=goto_split:left
```
<img width="223" height="106" alt="image"
src="https://github.com/user-attachments/assets/b80da251-9cff-4b29-b143-64854a5c4271"
/>
Surfaces only accept `a` as a trigger to select left split, not
`shift+a`
This commit is contained in:
@@ -29,8 +29,11 @@ extension Ghostty {
|
||||
}
|
||||
|
||||
case GHOSTTY_TRIGGER_UNICODE:
|
||||
guard let scalar = UnicodeScalar(trigger.key.unicode) else { return nil }
|
||||
key = KeyEquivalent(Character(scalar))
|
||||
guard
|
||||
let scalar = UnicodeScalar(trigger.key.unicode),
|
||||
let normalized = Character(scalar).lowercased().first
|
||||
else { return nil }
|
||||
key = KeyEquivalent(normalized)
|
||||
|
||||
case GHOSTTY_TRIGGER_CATCH_ALL:
|
||||
// catch_all matches any key, so it can't be represented as a KeyboardShortcut
|
||||
|
||||
@@ -220,4 +220,19 @@ struct ConfigTests {
|
||||
#expect(config.maximize == true)
|
||||
#expect(config.focusFollowsMouse == true)
|
||||
}
|
||||
|
||||
@Test
|
||||
func uppercasedLetterShouldBeNormalized() async throws {
|
||||
let config = try TemporaryConfig("""
|
||||
keybind=cmd+L=goto_split:left
|
||||
""")
|
||||
let shortcut = try #require(config.keyboardShortcut(for: "goto_split:left"))
|
||||
#expect(shortcut == .init("l", modifiers: [.command]))
|
||||
|
||||
let config2 = try TemporaryConfig("""
|
||||
keybind=cmd+Ä=goto_split:left
|
||||
""")
|
||||
let shortcut2 = try #require(config2.keyboardShortcut(for: "goto_split:left"))
|
||||
#expect(shortcut2 == .init("ä", modifiers: [.command]))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user