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

Lag after <space> in vim mode #13390

Closed aphorisme closed 2 months ago

aphorisme commented 2 months ago

First of all, thanks a lot for this amazing editor! : )

Check for existing issues

Describe the bug / provide steps to reproduce it

With vim_mode: true hitting the space bar takes about half a second, before the space is typed.

I have keybindings as follows:

{
    "context": "Editor && (vim_mode == normal || vim_mode == visual) && !VimWaiting && !menu",
    "bindings": {
      "space f f": "file_finder::Toggle",
      "space f o": "outline::Toggle",
      "space f s": "project_symbols::Toggle",
}

which might be a problem here, but even if I comment them out and restart the editor, the lag persists. (Maybe there is some caching but a way to reset, so I can test properly and use it as a workaround?) Changing space to . and restarting does not remove the lag. (Maybe the keybindings are irrelevant for this bug?)

A workaround changing "space" to something else is doable for me. But this might be still unexpected, since in vim_mode == insert no such bindings exist, but the lag happens in insert mode as well.

Setting vim_mode: false removes all lag.

Typing other characters works fine; the keybindings which use space react without a lag.

Environment

Zed: v0.140.5 (Zed) OS: macOS 14.5.0 Memory: 64 GiB Architecture: aarch64

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

I've made a gif. Some frames are omitted by the converter, but the overall feeling of the lag suits the reality: zed_space_lag

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

Zed.log

2024-06-22T14:12:09+02:00 [INFO] downloading language server "json-language-server"
2024-06-22T14:12:09+02:00 [INFO] Node runtime install_if_needed
2024-06-22T14:12:09+02:00 [INFO] starting language server. binary path: "/Users/aphorisme/Library/Application Support/Zed/node/node-v18.15.0-darwin-arm64/bin/node", working directory: "/Users/aphorisme/.config/zed", args: ["/Users/aphorisme/Library/Application Support/Zed/languages/json-language-server/node_modules/vscode-json-languageserver/bin/vscode-json-languageserver", "--stdio"]
2024-06-22T14:12:17+02:00 [INFO] open paths ["/Users/aphorisme/.config/zed/keymap.json"]
2024-06-22T14:12:17+02:00 [INFO] Initializing default prettier with plugins {}
2024-06-22T14:12:17+02:00 [INFO] Initializing default prettier with plugins {}
2024-06-22T14:12:17+02:00 [INFO] starting language servers for Markdown: 
2024-06-22T14:12:17+02:00 [INFO] starting language servers for JSON: json-language-server
2024-06-22T14:12:17+02:00 [INFO] Initializing default prettier with plugins {}
2024-06-22T14:12:17+02:00 [INFO] starting language servers for JSON: json-language-server
2024-06-22T14:12:17+02:00 [INFO] starting language server "json-language-server", path: "/Users/aphorisme/.config/zed/keymap.json", id: 2
2024-06-22T14:12:17+02:00 [INFO] starting language server. binary path: "/Users/aphorisme/Library/Application Support/Zed/node/node-v18.15.0-darwin-arm64/bin/node", working directory: "/Users/aphorisme/.config/zed", args: ["/Users/aphorisme/Library/Application Support/Zed/languages/json-language-server/node_modules/vscode-json-languageserver/bin/vscode-json-languageserver", "--stdio"]
2024-06-22T14:12:17+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
  "level": 1,
  "message": "[INFO] [ghostText] [2024-06-22T12:12:17.244Z] Cancelled during debounce",
  "metadataStr": "[INFO] [ghostText] [2024-06-22T12:12:17.244Z]",
  "extra": [
    "Cancelled during debounce"
  ]
}
2024-06-22T14:14:34+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
  "level": 1,
  "message": "[INFO] [default] [2024-06-22T12:14:34.792Z] [fetchCompletions] engine https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex",
  "metadataStr": "[INFO] [default] [2024-06-22T12:14:34.792Z]",
  "extra": [
    "[fetchCompletions] engine https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex"
  ]
}
2024-06-22T14:14:35+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
  "level": 1,
  "message": "[INFO] [default] [2024-06-22T12:14:35.163Z] [fetchCompletions] engine https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex",
  "metadataStr": "[INFO] [default] [2024-06-22T12:14:35.163Z]",
  "extra": [
    "[fetchCompletions] engine https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex"
  ]
}
2024-06-22T14:14:35+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
  "level": 1,
  "message": "[INFO] [default] [2024-06-22T12:14:35.357Z] [fetchCompletions] engine https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex",
  "metadataStr": "[INFO] [default] [2024-06-22T12:14:35.357Z]",
  "extra": [
    "[fetchCompletions] engine https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex"
  ]
}
2024-06-22T14:14:35+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
  "level": 1,
  "message": "[INFO] [default] [2024-06-22T12:14:35.557Z] [fetchCompletions] engine https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex",
  "metadataStr": "[INFO] [default] [2024-06-22T12:14:35.557Z]",
  "extra": [
    "[fetchCompletions] engine https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex"
  ]
}
2024-06-22T14:14:35+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
  "level": 1,
  "message": "[INFO] [default] [2024-06-22T12:14:35.764Z] request.response: [https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex/completions] took 207 ms",
  "metadataStr": "[INFO] [default] [2024-06-22T12:14:35.764Z]",
  "extra": [
    "request.response: [https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex/completions] took 207 ms"
  ]
}
2024-06-22T14:14:35+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
  "level": 1,
  "message": "[INFO] [streamChoices] [2024-06-22T12:14:35.768Z] solution 0 returned. finish reason: [stop]",
  "metadataStr": "[INFO] [streamChoices] [2024-06-22T12:14:35.768Z]",
  "extra": [
    "solution 0 returned. finish reason: [stop]"
  ]
}
2024-06-22T14:14:35+02:00 [INFO] Language server with id 0 sent unhandled notification LogMessage:
{
  "level": 1,
  "message": "[INFO] [streamChoices] [2024-06-22T12:14:35.770Z] request done: headerRequestId: [00339f08-a3cd-42c1-aac9-38746ee82e78] model deployment ID: [z6953999e1f31]",
  "metadataStr": "[INFO] [streamChoices] [2024-06-22T12:14:35.770Z]",
  "extra": [
    "request done: headerRequestId: [00339f08-a3cd-42c1-aac9-38746ee82e78] model deployment ID: [z6953999e1f31]"
  ]
}

amassare commented 2 months ago
{
    "context": "Editor && (vim_mode == normal || vim_mode == visual) && !VimWaiting && !menu",
    "bindings": {
      "space f f": "file_finder::Toggle",
      "space f o": "outline::Toggle",
      "space f s": "project_symbols::Toggle",
}

Except these keybindings,do your have any keybindings related to "space" key?

aphorisme commented 2 months ago

Omg. I'm so sorry. I was about posting my complete keybindings and there seems to be what can only be an artifact of some old edit: there was indeed a keybinding in the "vim_mode == insert" section with a "space" key in there ..

Removing it solved all lag ...

It was:

      "space ctrl-j": "copilot::NextSuggestion"

so everything makes sense to me. I would close this. Sorry for the misleading ticket!