Fix crash with ¨ key (fix #1470)

This commit is contained in:
1024jp 2023-04-08 19:04:08 +09:00
parent 8a7927d5dd
commit fde75e89dc
2 changed files with 6 additions and 2 deletions

View File

@ -12,6 +12,7 @@ Change Log
### Fixes
- Fix an issue that the application crashed by typing the ¨ key with a Norwegian keyboard.
- Fix an issue that the editor font did not applied to documents created via Services.

View File

@ -146,7 +146,10 @@ struct Shortcut {
assert(event.type == .keyDown)
guard let charactersIgnoringModifiers = event.charactersIgnoringModifiers else { return nil }
guard
let charactersIgnoringModifiers = event.charactersIgnoringModifiers,
charactersIgnoringModifiers.count == 1
else { return nil }
// correct Backspace and Forward Delete keys
// -> Backspace: The key above the Return.
@ -334,7 +337,7 @@ extension Shortcut: Equatable {
let modifierMask = self.modifierMask.union(needsShift ? .shift : [])
let keyEquivalent = self.keyEquivalent.lowercased()
return Shortcut(modifierMask: modifierMask, keyEquivalent: keyEquivalent)!
return Shortcut(modifierMask: modifierMask, keyEquivalent: keyEquivalent) ?? self
}
}