zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
41.76k stars 2.18k forks source link

Custom system shortcuts not accepted. #11663

Open krstp opened 2 months ago

krstp commented 2 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

It happened the MacOS custom system shortcuts stopped being accepted within ZED. In particular, I have system-wide defined shortcut to ZOOM the operational window, such as CMD+OPT+z, which will maximize any system window to full screen size. As such, since one of recent releases the shortcut stopped working in ZED (of course still works in other applications).

I reckon, the issue might be related to F keys being outright ignored: https://github.com/zed-industries/zed/issues/11618#issuecomment-2104799616

Environment

Zed: v0.135.1 (Zed Preview) OS: macOS 14.4.1 Memory: 32 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

See description above.

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

There is no log generated for the event as if the key combination was outright ignored

TeamPuzel commented 1 month ago

Zed is not following the Cocoa documentation 😉 and is not adding the Services menu item which is what contains global shortcuts.

Relevant docs: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/SysServices/Articles/menu.html

The Services menu is included in the default nib file created by Xcode and Interface Builder for Cocoa applications. If the application’s menu is instead created programmatically, you need to designate a Services menu using the NSApplication method setServicesMenu:. If an application registers for services (see Using Services), the appropriate items are automatically available in the Services menu.

It should be possible to fix in a few lines of code.

It should go here:

image

By the way, I assume this is referring to global shortcuts defined by services — since if you were to add your shortcut from the Keyboard settings:

image

then it should work in any application as long as it has the menu item

krstp commented 4 weeks ago

Correct, this refers to global shortcut.