sindresorhus / KeyboardShortcuts

⌨️ Add user-customizable global keyboard shortcuts (hotkeys) to your macOS app in minutes
https://swiftpackageindex.com/sindresorhus/KeyboardShortcuts/documentation/keyboardshortcuts/keyboardshortcuts
MIT License
1.94k stars 181 forks source link

Annotate `Shortcut/description` with @MainActor to prevent crashes #162

Closed greimers closed 6 months ago

greimers commented 7 months ago

The private function keyToCharacter() has an assert to make sure it is only called on the Main thread because TISGetInputSourceProperty will crash on background threads.

It would be great if Shortcut.description (which uses keyToCharacter()) had an @MainActor annotation to prevent running into issues here. I don't know if that has any implications with backwards compatibility, however.