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
46.58k stars 2.64k forks source link

Cant rebind tab from editor:ConfirmCompletion #4752

Closed gregorypease280 closed 1 week ago

gregorypease280 commented 1 year ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I can't tell if this just isn't supported or a bug. I'm trying to make it so tab will cycle through auto complete options instead of selecting one. Is there a way to even unbind a key completely? Perhaps it's because menu::SelectNext is not valid in this context.

I also don't believe there are any errors being reported if keymap.json is invalid in any way?

my keymap.json

    {
        "bindings": {
            "cmd-l": "workspace::NewTerminal"
        }
    },
    {
      "context": "Editor && showing_completions",
      "bindings": {
        "tab": "menu::SelectNext",
        "shift-tab": "menu::SelectPrev",
        "enter": "editor::ConfirmCompletion"
      }
    }
]

Environment

Zed: v0.85.3 (stable) OS: macOS 13.3.1 Memory: 16 GiB Architecture: x86_64

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

ideally I think the keymap should look somethign like this. `[

{
  "context": "Editor && showing_completions",
  "bindings": {
    "tab": "editor::SelectNextCompletion",
    "shift-tab": "editor::SelectPreviousCompletion",
    "enter": "editor::ConfirmCompletion"
  }
}

] `

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

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

JosephTLyons commented 1 year ago

It is hard for me to tell as well. We have a bit of work to do on our keymap system - it could use some polish. I think this is some limitation with the system at the moment.

gregorypease280 commented 1 year ago

Thanks for taking a look! My hunch is that a no-op bind might be the quickest fix for cases like these.

taylorthurlow commented 6 months ago

I thought that zed::NoAction might be what was needed here, but it does actually no-op it rather than just passing through the underlying key. What I'm hoping to achieve here is to be able to, for example, unbind enter from triggering editor::ConfirmCompletion, so that instead of doing nothing when I hit enter, it inserts a newline.

Not sure if it makes sense in the model that Zed is going for, but what I think would solve my problem here is the ability to map enter to a sequence of commands like ["editor::Cancel", ["editor::SendKeystroke", "enter"]], similar to how we can already send keystrokes to the terminal.

VKondakoff commented 5 months ago

So, currently there still is no command to to cycle through auto-complete options?

notpeter commented 1 week ago

There are now keys/actions in the default keymap that support this. Docs: Using Inline Completions

https://github.com/zed-industries/zed/blob/5586397f952bdf34590b2d1a1097071dbd987a7d/assets/keymaps/default-macos.json#L152-L159

If you don't want tab to do this you'll have to unnbind the default: https://github.com/zed-industries/zed/blob/5586397f952bdf34590b2d1a1097071dbd987a7d/assets/keymaps/default-macos.json#L480-L485

With something like:

 { 
   "context": "Editor && inline_completion && !showing_completions", 
   "bindings": { 
     "tab": "editor::Tab", 
   } 
 },

Happy to reopen if that doesn't solve your issue, just leave a comment. Thanks.