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.9k stars 2.69k forks source link

Pressing [Tab] to accept copilot suggestion doesn't work when using VIM mode #16552

Open isdampe opened 3 weeks ago

isdampe commented 3 weeks ago

Check for existing issues

Describe the bug / provide steps to reproduce it

Steps to reproduce:

  1. Enable copilot and turn on vim mode.
  2. Enter insert mode (i)
  3. Start typing and wait for a copilot suggestion
  4. When copilot suggestion appears, press [Tab]
  5. Observe that a tab character is inserted - but the suggestion is ignored / disappears

Environment

Zed: v0.149.3 (Zed) OS: macOS 14.3.1 Memory: 24 GiB Architecture: aarch64

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

No response

If applicable, attach your Zed.log file to this issue.

No response

ConradIrwin commented 3 weeks ago

@isdampe Same for this one. Could you please paste your complete key binding file?

nabn commented 3 weeks ago

I'm seeing the same.

[
  {
    "context": "Editor",
    "bindings": {
      "gd": "editor::GoToDefinition",
      "shift-tab": "editor::Tab",
      "tab": "editor::TabPrev",
      "shift-left": "pane::ActivatePrevItem",
      "shift-right": "pane::ActivateNextItem",
      "shift-c": "pane::CloseActiveItem"
    }
  },
  {
    "context": "vim_mode_insert",
    "bindings": {
      "tab": "editor::AcceptInlineCompletion"
    }
  },
  {
    "context": "vim_mode_normal",
    "bindings": {
      "g r": "editor::FindAllReferences",
      "e p": "editor::GoToPrevDiagnostic",
      "e n": "editor::GoToDiagnostic",
      ", c u": "editor::RevertSelectedHunks"
    }
  }
]

I have tried with and without the vim insert mode keymap

ConradIrwin commented 3 weeks ago

@nabn It should work by default, so you shouldn't need anything. That said, there is some work to fix the keymap you have there.

The way that key bindings work, your bindings will override all of the default ones; so overriding "tab" to be "editor::TabPrev" will override the default behavior.

If you want to override "tab" and keep the completion stuff you need to copy some of the default keymap into yours so that if completions are showing you can override your override:

[
  {
    "context": "Editor",
    "bindings": {
      "tab": "editor::TabPrev",
      ...
    }
  },

  // https://github.com/zed-industries/zed/blob/4237671f649b0ad60f1934a08a0015042b80daf7/assets/keymaps/default-linux.json#L438
  {
    "context": "Editor && showing_completions",
    "bindings": {
      "tab": "editor::ComposeCompletion"
    },
  {

    // https://github.com/zed-industries/zed/blob/4237671f649b0ad60f1934a08a0015042b80daf7/assets/keymaps/default-linux.json#L444
     "context": "Editor && inline_completion && !showing_completions",
    "bindings": {
      "tab": "editor::AcceptInlineCompletion"
  }
]