Skip to content

Commit

Permalink
Fix duplication checking with menu items for shortcuts with a Shift m…
Browse files Browse the repository at this point in the history
…odifier (#88)

Co-authored-by: Sindre Sorhus <[email protected]>
  • Loading branch information
megabitsenmzq and sindresorhus authored Jun 26, 2022
1 parent 660c11e commit 1522654
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Sources/KeyboardShortcuts/Shortcut.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,17 @@ extension KeyboardShortcuts.Shortcut {
*/
func menuItemWithMatchingShortcut(in menu: NSMenu) -> NSMenuItem? {
for item in menu.items {
var keyEquivalent = item.keyEquivalent
var keyEquivalentModifierMask = item.keyEquivalentModifierMask

if modifiers.contains(.shift) {
keyEquivalent = keyEquivalent.lowercased()
keyEquivalentModifierMask.insert(.shift)
}

if
keyToCharacter() == item.keyEquivalent,
modifiers == item.keyEquivalentModifierMask
keyToCharacter() == keyEquivalent,
modifiers == keyEquivalentModifierMask
{
return item
}
Expand Down

0 comments on commit 1522654

Please sign in to comment.