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
50.77k stars 3.15k forks source link

Breaking Keybinding Changes 2024-11-13 #20425

Open notpeter opened 2 weeks ago

notpeter commented 2 weeks ago

We are making multiple changes to how keyboards work in Zed. The first two affect all platforms, the remaining three affect only macOS.

For the thinking behind this, please see Zed Blog: macOS Keyboard Shortcut Localization.

1. Removal of alt- only key bindings.

As of Zed v0.162.x (released as Zed Preview on 2024-11-13 and Zed Stable on 2024-11-20) Zed will be removing a number of keyboard shortcuts which of the form alt-N / option-N where N is a single letter.

The purpose of this change is to better accommodate users of non-US keyboards in the default Zed configuration. On these keyboards, these default shortcuts prevented the use of non-ASCII characters required for these languages.

If you wish to continue using these, you will need to explicitly add them to your User keymap (~/.config/zed/keymap.json) which is accessible via the zed: open keymap action from the command palette or by pressing cmd-k cmd-s (Mac) or ctrl-k ctrl-s (Linux/Win).

[
  {
    "context": "Editor",
    "bindings": {
      "alt-b": "editor::MoveToPreviousWordStart",
      "alt-d": "editor::DeleteToNextWordEnd",
      "alt-f": "editor::MoveToNextWordEnd",
      "alt-h": "editor::DeleteToPreviousWordStart",
      "alt-q": "editor::Rewrap",
      "alt-v": ["editor::MovePageUp", { "center_cursor": true }]
    }
  },
  {
    "context": "Editor && mode == full",
    "bindings": {
      "alt-z": "editor::ToggleSoftWrap"
    }
  },
  {
    "context": "AssistantPanel",
    "bindings": {
      "alt-m": "assistant::ToggleModelSelector"
    }
  }
]

We appreciate your understanding an apologize for any disruption this may cause.

2. Inline Completion (Copilot, SuperMaven) Partial Completion Acceptance

On MacOS, the default keyboard shortcut bound to editor::AcceptPartialInlineCompletion will now be ctrl-right instead of cmd-right.

On Linux, the default keyboard shortcut bound to editor::AcceptPartialInlineCompletion will now be alt-right instead of ctrl-right.

3. Updated shortcuts for extended Latin keyboards

On macOS when using a keyboard that supports an extended Latin character set (e.g. French, German, ...) keyboard shortcuts are now automatically updated so that they can be typed without option. This fixes several long-standing problems where some keyboards could not type some shortcuts.

This mapping works the same way as macOS. For example on a German keyboard shortcuts like cmd-> become cmd-:, cmd-[ and cmd-] become cmd-ö and cmd-ä. This mapping happens at the time keyboard layout files are read so the new keybindings are visible in the command palette by searching for an action. To opt out of this behavior for your custom keyboard shortcuts, set "use_layout_keys": true in your binding section. For the keys affected on each layout see here.

This does not affect Vim mode, as Vim's shortcuts use layout keys to make them more compatible with Vim.

4. Updated shortcut handling for non-Latin keyboards

On macOS when using a keyboard that types a non-Latin character set (e.g. Armenian, Cyrillic), bindings bound to latin characters are more reliable. Zed will now always try to use the character from your keyboard's command layout (which is usually QWERTY) when matching bindings, instead of only doing this when the command key is held down.

This allows you to use Vim's normal mode without switching keyboard, and makes bindings like ctrl-a for select all accessible.

5. Dispatching shortcuts before IME

Keyboard shortcuts will now be dispatched before trigging the IME system. This primarily affects vim mode on keyboards with IME menus (like Japanese), where you'll now be able to use vim normal mode without switching input.

It also changes the behavior on Extended Latin keyboards with dead keys. For example ^ will go to the beginning of a line in vim mode, even if it would normally be a dead key. This is a departure from vim, where you would have to type ^ space. Note that some mappings still require the space. For example: d f ^ space is needed because you might want to do d f â instead.

hedefalk commented 1 week ago

Thanks a lot for taking the effort for us non-US users! I know I've reported a couple of times when shortcuts made me not be able to type normally on my SE localed mac after updating zed.

I missed the heads up this time though so another breakage today — had gotten used to "cmd-right" for copilot assistance which wasn't working just this morning. Easy fix after finding this post:

"cmd-right": "editor::AcceptPartialInlineCompletion"

ctrl-right I have bound to switching workspaces/desktops in MacOS. I thought this was standard, but I might be mistaken…?

minimo-io commented 1 week ago

Hi, spanish keyboard on Mac Mini M1 here. My lovely Zed just broke the keybindings after the last update (v0.162.3). Unfortunately now a cmd-f (buffer search) opens a new buffer panel to the right.

(edit for extra details)

Example, this will open the help menu item, despite my keymap config.

    {
        "context": "Editor",
        "bindings": {
            "cmd-/": ["editor::ToggleComments", { "advance_downwards": false }]
        }
    },

Similar problems with project search, and split right binding to cmd-f instead of search (this last one was fixable by editing my my keymap.json config)

Screenshot 2024-11-21 at 12 46 07-zed

cristianorvf commented 1 week ago

Hello, seems 0.162.3 (this "keyboard" pack) broke some things on US keyboards also (or maybe some config name changed .. idk).

Screenshot 2024-11-21 at 15 04 25

Screenshot 2024-11-21 at 15 03 49

The follow keybindings stopped working ("shift" U, K, J). The combination basically wont respond.

Screenshot 2024-11-21 at 15 00 22

Other bindings involving CMD, or lower case still works (ex. cmd-] .. space f etc..)

ConradIrwin commented 1 week ago

@cristianorvf Sorry about this! Those bindings should be spelled shift-u and shift-k and shift-j in Zed. That said, I didn't intend to break them, and they'll be fixed in the next patch release.

cristianorvf commented 1 week ago

@cristianorvf Sorry about this! Those bindings should be spelled shift-u and shift-k and shift-j in Zed. That said, I didn't intend to break them, and they'll be fixed in the next patch release.

Thanks, is working again now.

minimo-io commented 6 days ago

Most things seems solved after the last update, with one exception: comments shortcut keep opening the "Help" menu item in spanish keyboards. So, comments are cmd-/ which in spanish keyboard results in cmd-(shift)-/. Opening the help menu item.

BTW: Is this the right place for posting this?

ConradIrwin commented 6 days ago

@minimo-io can you confirm which layout you're on (look in debug: Open Key Context View). For me using the Spanish ISO comments are on /, which is typed with shift+7?

minimo-io commented 6 days ago

debug: Open Key Context View

Sure @ConradIrwin I am using a spanish magic keyboard (apple), more details in the first screen-cap.

3 screenshots
ConradIrwin commented 6 days ago

@minimo-io wierd... that is acting pretty much how I expect, except that the help menu opens for you.

I notice in my settings that I have this keybinding available, but disabled. (And even if I enable it, I don't get the problem you see)

Do you have anything similar?

Screenshot 2024-11-22 at 09 56 57
minimo-io commented 6 days ago

Do you have anything similar?

Weird indeed! I checked and had that OS option enabled, after disabling it and trying to comment again, the help menu does not open anymore but still cannot comment lines (nothing happens). To keep things usable i changed the key-binding to cmd-shift-g, I suppose i can get use to sth like that.

Let me know if I can help in any other way. I am using a Mac Mini M1 (2020), OS version 15.1.1 (Sequoia), system language is English, keyboard in Spanish, details above. Thanks!

mdelete commented 3 days ago

I stumbled upon this myself just now, after a lengthy phase of avoiding the sequoia update, and thanks to @ConradIrwin's comment I quickly found the reason why now suddenly the help-menu pops up. Now the weird part: I'm using the default keybindings in zed, german keyboard, which is similar to spanish with regard to cmd-shift-7 for comment lines. I'm also using Xcode, which recently shifted toggle comments to cmd-ß (should be cmd-´ in spanish) and this shortcut also works in zed without being configured.

ivansigmund commented 3 days ago

i have an issue that i am unable to write the backslash "\" in zed (and only in zed). I'm using the croatian keyboard layout, and there the \ is written as "⌥ž". "⌥ć" produces normal ^ . here is a video:

https://github.com/user-attachments/assets/7c38b72d-f216-418f-ab2a-24ca32ea393a

Dracks commented 3 days ago

Hey,

In spanish keyboard (mac os Sequoia), previously cmd+. was the code-action quick fix (the same as in vscode) but is not anymore, now it's simply the comment line. I writed this https://github.com/zed-industries/zed/issues/21155, but I think I should close it there, right?

Thanks.

bakkdoor commented 3 days ago

I am using a german keyboard layout, and cmd-/ stopped working for commenting out lines.

I noticed that it works if I press the key next to it (cmd-&) on the german keyboard even though I am using the default keybinding:

"cmd-/": ["editor::ToggleComments", { "advance_downwards": false }],

If I add a custom keybinding for it it works again with cmd-/ if I set it up with the key to the left of it via:

"cmd-&": ["editor::ToggleComments", { "advance_downwards": false }],
notpeter commented 2 days ago

I'd like to avoid this thread from getting too large so I'm going to hide some replies above and roll them into individual issues or notes in this comment.

Associated issues:

injust commented 2 days ago

ctrl-right I have bound to switching workspaces/desktops in MacOS. I thought this was standard, but I might be mistaken…?

Yeah, this is a standard macOS shortcut. I haven't tested how it interacts with Zed's new keybinding, but I imagine it could result in some funny behaviour.