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
48.91k stars 2.94k forks source link

Alt/option key related shortcuts not working in mac m1 #10236

Open auspy opened 6 months ago

auspy commented 6 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

My device

Mac m1 8gb 256gb

Description

i tried adding custom keybindings base on alt/option key but they are not working.

Example of keybindings i tried:

  {
    "context": "Editor && vim_mode == normal", 
    "bindings": {
      "alt-h": "editor::MoveToPreviousWordStart",
      "alt-l": "editor::MoveToNextWordEnd"
    }
  }

Environment

Mac m1 8gb 256gb

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

No response

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

No response

jborkowski commented 6 months ago

Hey @auspy,

I've just tried reproducing your problem on my Mac, and I cannot. For me, everything works as expected. Here is my configuration:

[
  {
    "context": "Editor && vim_mode == normal",
    "bindings": {
      "alt-h": "editor::MoveToPreviousWordStart",
      "alt-l": "editor::MoveToNextWordEnd"
    }
  }
]

I tried on macOS Sonoma 14.4.1 and Zed 0.131.6. Could you give me any reproduction steps?

auspy commented 6 months ago

Hey @auspy,

I've just tried reproducing your problem on my Mac, and I cannot. For me, everything works as expected. Here is my configuration:

[
  {
    "context": "Editor && vim_mode == normal",
    "bindings": {
      "alt-h": "editor::MoveToPreviousWordStart",
      "alt-l": "editor::MoveToNextWordEnd"
    }
  }
]

I tried on macOS Sonoma 14.4.1 and Zed 0.131.6. Could you give me any reproduction steps?

i am using macOS Sonoma 14.1.1 and zed 0.131.6. I tested the snippet you sent and it's not working

jborkowski commented 6 months ago

Interesting, maybe macOS captures these shortcuts? I will try to reproduce this on a different MBP.

notpeter commented 2 months ago

I am not able to reproduce this either, adding these keybinds worked as expected.

Your original snippet was not valid JSON (extra comma). In the Zed version when this issue was filed, invalid json would (silently) prevent a keymap from being applied. We've subsequently improved validation support to settings/keymaps which will automatically fix small issue (excess commas) and throw an error with an invalid configuration.

If you are still experiencing this issue, please feel free to comment and I'm happy to reopen.

LogicKahanHai commented 1 month ago

Was any solution found for this? I am also not able to get these 'alt' specific key binds to work.

Here is my keymaps file

  {
    "context": "Editor && vim_mode==normal",
    "bindings": {
      "alt-h": ["workspace::ActivatePaneInDirection", "Left"], // All of these don't work 
      "alt-j": ["workspace::ActivatePaneInDirection", "Down"],
      "alt-k": ["workspace::ActivatePaneInDirection", "Up"],
      "alt-l": ["workspace::ActivatePaneInDirection", "Right"]
    }
  },
  {
    "context": "Editor && vim_mode==normal && vim_operator == none && !VimWaiting",
    "bindings": {
      //... some other non-clashing keybinds

      "space m h": ["workspace::ActivatePaneInDirection", "Left"] // This works
    }

My Mac version: Sequoia 15.0 Zed version: 0.153.6

notpeter commented 1 month ago

This may be a Sequoia specific issue. @auspy are you also running Sequoia?

LogicKahanHai commented 1 month ago

This may be a Sequoia specific issue.

@notpeter I think it is not that, cuz I was using zed for a few days before upgrading to Sequoia. I reckon it's related to alt key being auto-mapped to option key in the mac native keyboard and there are these annoying keystrokes with option key that get triggered when these combinations are pressed. I have also noticed a ? appearing at the cursor location when I put the key combo.

I am sorry, but I am fairly new to all of this (mac, vim, and zed) and when I researched a bit about this ? appearing I found all these details. Is it possible that you have disabled those special characters and so you're zed is able to capture the option keystroke? If yes, can you please share some resource to do that? I tried stackoverflow's answer but it was very complicated for me to follow. Thanks for your help! :)

Edit These are the special symbols I was talking about: -

  1. ˝ - alt-j
  2. ˚ - alt-k
      • alt-l

etc...