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
49.26k stars 2.98k forks source link

LSP client doesnt seem to respect server's text document sync options #6322

Closed mhanberg closed 1 year ago

mhanberg commented 1 year ago

Check for existing issues

Describe the bug / provide steps to reproduce it

servers can specify how the client should sent document changes: full, incremental, or none. Next LS specifies "full", but Zed seems to be sending incremental updates, which is causing problems with formatting.

steps:

open an elixir project using the Next LS LSP server.

open the RPC logs

open an elixir file

wait for it all to be compiled

make a change

observer that the client sends an incremental update to rather than the full text

// Send:
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///Users/mitchell/src/btcticker/lib/btcticker_web.ex","languageId":"","version":0,"text":"defmodule BtctickerWeb do\n  @moduledoc \"\"\"\n  The entrypoint for defining your web interface, such\n  as controllers, views, channels and so on.\n\n  This can be used in your application as:\n\n      use BtctickerWeb, :controller\n      use BtctickerWeb, :view\n\n  The definitions below will be executed for every view,\n  controller, etc, so keep them short and clean, focused\n  on imports, uses and aliases.\n\n  Do NOT define functions inside the quoted expressions\n  below. Instead, define any helper function in modules\n  and import those modules here.\n  \"\"\"\n\n  def controller do\n    quote do\n      use Phoenix.Controller, namespace: BtctickerWeb\n\n      import Plug.Conn\n      import BtctickerWeb.Gettext\n      alias BtctickerWeb.Router.Helpers, as: Routes\n    end\n  end\n\n  def view do\n    quote do\n      use Phoenix.View,\n        root: \"lib/btcticker_web/templates\",\n        namespace: BtctickerWeb\n\n      # Import convenience functions from controllers\n      import Phoenix.Controller,\n        only: [get_flash: 1, get_flash: 2, view_module: 1, view_template: 1]\n\n      # Include shared imports and aliases for views\n      unquote(view_helpers())\n    end\n  end\n\n  def live_view do\n    quote do\n      use Phoenix.LiveView,\n        layout: {BtctickerWeb.LayoutView, \"live.html\"}\n\n      unquote(view_helpers())\n    end\n  end\n\n  def live_component do\n    quote do\n      use Phoenix.LiveComponent\n\n      unquote(view_helpers())\n    end\n  end\n\n  def component do\n    quote do\n      use Phoenix.Component\n\n      unquote(view_helpers())\n    end\n  end\n\n  def router do\n    quote do\n      use Phoenix.Router\n\n      import Plug.Conn\n      import Phoenix.Controller\n      import Phoenix.LiveView.Router\n    end\n  end\n\n  def channel do\n    quote do\n      use Phoenix.Channel\n      import BtctickerWeb.Gettext\n    end\n  end\n\n  defp view_helpers do\n    quote do\n      # Use all HTML functionality (forms, tags, etc)\n      use Phoenix.HTML\n\n      # Import LiveView and .heex helpers (live_render, live_patch, <.form>, etc)\n      import Phoenix.LiveView.Helpers\n\n      # Import basic rendering functionality (render, render_layout, etc)\n      import Phoenix.View\n\n      import BtctickerWeb.ErrorHelpers\n      import BtctickerWeb.Gettext\n      alias BtctickerWeb.Router.Helpers, as: Routes\n    end\n  end\n\n  @doc \"\"\"\n  When used, dispatch to the appropriate controller/view/etc.\n  \"\"\"\n  defmacro __using__(which) when is_atom(which) do\n    apply(__MODULE__, which, [])\n  end\nend\n"}}}
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/mitchell/src/btcticker/lib/btcticker_web.ex","version":1},"contentChanges":[{"range":{"start":{"line":6,"character":0},"end":{"line":6,"character":0}},"text":"\n  "}]}}
{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///Users/mitchell/src/btcticker/lib/btcticker_web.ex","version":2},"contentChanges":[]}}

Environment

Zed: v0.106.0 (preview) OS: macOS 13.5.2 Memory: 8 GiB Architecture: aarch64

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.

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

2023-09-27T19:36:14 [INFO] ========== starting zed ========== 2023-09-27T19:36:14 [INFO] Opening main db 2023-09-27T19:36:15 [ERROR] crates/settings/src/settings_file.rs:90: EOF while parsing a value at line 1 column 0 2023-09-27T19:36:15 [INFO] Opening main db 2023-09-27T19:36:15 [WARN] request completed with error: failed to resolve host name 2023-09-27T19:36:15 [ERROR] crates/copilot/src/copilot.rs:958: error fetching latest release

Caused by: 0: failed to resolve host name 1: [6] Couldn't resolve host name 2023-09-27T19:36:15 [WARN] request completed with error: failed to resolve host name 2023-09-27T19:36:15 [ERROR] auto-update failed: error:failed to resolve host name

Caused by: [6] Couldn't resolve host name 2023-09-27T19:36:16 [INFO] set environment variables from shell:/opt/homebrew/bin/zsh, path:/Users/mitchell/zls/zig-out/bin:/Applications/Sublime Text.app/Contents/SharedSupport/bin:/Users/mitchell/go/bin:/Users/mitchell/Library/Python/2.7/bin:/Users/mitchell/Library/Python/3.8/bin:/Users/mitchell/Library/Python/3.9/bin:/Users/mitchell/.cargo/bin:/Users/mitchell/.bin:/opt/homebrew/opt/sqlite/bin:/opt/homebrew/bin/qt@5.5/bin:/Users/mitchell/.local/share/zinit/polaris/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/mitchell/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin 2023-09-27T19:37:02 [INFO] open paths ["/Users/mitchell/.config/zed/settings.json"] 2023-09-27T19:37:02 [INFO] Opening main db 2023-09-27T19:37:02 [INFO] starting language server "json-language-server", path: "/Users/mitchell/.config/zed/settings.json", id: 1 2023-09-27T19:37:02 [INFO] Node runtime install_if_needed 2023-09-27T19:37:14 [INFO] Node runtime install_if_needed 2023-09-27T19:37:18 [INFO] Node runtime install_if_needed 2023-09-27T19:37:26 [ERROR] /Users/administrator/actions-runner-2/_work/zed/zed/crates/install_cli/src/install_cli.rs:21: Os { code: 2, kind: NotFound, message: "No such file or directory" } 2023-09-27T19:37:26 [ERROR] /Users/administrator/actions-runner-2/_work/zed/zed/crates/install_cli/src/install_cli.rs:24: Os { code: 13, kind: PermissionDenied, message: "Permission denied" } 2023-09-27T19:38:00 [ERROR] oneshot canceled 2023-09-27T19:38:19 [INFO] build git repository ".git" 2023-09-27T19:38:24 [INFO] starting language server "elixir-ls", path: "/Users/mitchell/src/next_ls", id: 2 2023-09-27T19:38:56 [ERROR] unexpected item event after pane was dropped 2023-09-27T19:38:57 [INFO] 2 unhandled notification window/logMessage: { "message": "Started ElixirLS v0.16.0", "type": 3 } 2023-09-27T19:38:57 [INFO] 2 unhandled notification window/logMessage: { "message": "Running in /Users/mitchell/src/next_ls", "type": 3 } 2023-09-27T19:38:57 [INFO] 2 unhandled notification window/logMessage: { "message": "ElixirLS built with elixir \"1.15.5\" on OTP \"26\"", "type": 3 } 2023-09-27T19:38:57 [INFO] 2 unhandled notification window/logMessage: { "message": "Running on elixir \"1.15.5 (compiled with Erlang/OTP 26)\" on OTP \"26\"", "type": 3 } 2023-09-27T19:38:57 [INFO] 2 unhandled notification window/logMessage: { "message": "Protocols are not consolidated", "type": 3 } 2023-09-27T19:38:57 [INFO] 2 unhandled notification window/logMessage: { "message": "Elixir sources not found (checking in /private/tmp/elixir-20230828-6830-14xd5rx/elixir-1.15.5). Code navigation to Elixir modules disabled.", "type": 3 } 2023-09-27T19:38:57 [INFO] 2 unhandled notification window/showMessage: { "message": "Building core Dialyzer Elixir PLT. This will take a few minutes (often 15+) and can be disabled in the settings.", "type": 3 } 2023-09-27T19:39:27 [ERROR] unexpected item event after pane was dropped 2023-09-27T19:39:54 [INFO] 2 unhandled notification window/showMessage: { "message": "Saved Elixir PLT to /Users/mitchell/.mix/elixir-ls-26.0.2_elixir-1.15.5", "type": 3 } 2023-09-29T04:25:10 [ERROR] oneshot canceled 2023-09-29T04:25:18 [INFO] ========== starting zed ========== 2023-09-29T04:25:18 [INFO] Opening main db 2023-09-29T04:25:18 [INFO] Opening main db 2023-09-29T04:25:18 [INFO] build git repository ".git" 2023-09-29T04:25:19 [INFO] set environment variables from shell:/opt/homebrew/bin/zsh, path:/Users/mitchell/zls/zig-out/bin:/Applications/Sublime Text.app/Contents/SharedSupport/bin:/Users/mitchell/go/bin:/Users/mitchell/Library/Python/2.7/bin:/Users/mitchell/Library/Python/3.8/bin:/Users/mitchell/Library/Python/3.9/bin:/Users/mitchell/.cargo/bin:/Users/mitchell/.bin:/opt/homebrew/opt/sqlite/bin:/opt/homebrew/bin/qt@5.5/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/mitchell/.local/share/rtx/installs/swift/5.9/bin:/Users/mitchell/.local/share/rtx/installs/elixir/1.14.5-otp-25/bin:/Users/mitchell/.local/share/rtx/installs/elixir/1.14.5-otp-25/.mix/escripts:/Users/mitchell/.local/share/rtx/installs/erlang/25.3.2.5/bin:/Users/mitchell/.local/share/rtx/installs/neovim/nightly/bin:/Users/mitchell/zls/zig-out/bin:/Applications/Sublime Text.app/Contents/SharedSupport/bin:/Users/mitchell/go/bin:/Users/mitchell/Library/Python/2.7/bin:/Users/mitchell/Library/Python/3.8/bin:/Users/mitchell/Library/Python/3.9/bin:/Users/mitchell/.cargo/bin:/Users/mitchell/.bin:/opt/homebrew/opt/sqlite/bin:/opt/homebrew/bin/qt@5.5/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/mitchell/.local/share/rtx/installs/swift/5.9/bin:/Users/mitchell/.local/share/rtx/installs/elixir/1.14.5-otp-25/bin:/Users/mitchell/.local/share/rtx/installs/elixir/1.14.5-otp-25/.mix/escripts:/Users/mitchell/.local/share/rtx/installs/erlang/25.3.2.5/bin:/Users/mitchell/.local/share/rtx/installs/neovim/nightly/bin:/opt/homebrew/bin:/Users/mitchell/zls/zig-out/bin:/Applications/Sublime Text.app/Contents/SharedSupport/bin:/Users/mitchell/go/bin:/Users/mitchell/Library/Python/2.7/bin:/Users/mitchell/Library/Python/3.8/bin:/Users/mitchell/Library/Python/3.9/bin:/Users/mitchell/.cargo/bin:/Users/mitchell/.bin:/opt/homebrew/opt/sqlite/bin:/opt/homebrew/bin/qt@5.5/bin:/Users/mitchell/.local/share/zinit/polaris/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/mitchell/.nix-profile/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin 2023-09-29T04:25:20 [INFO] Node runtime install_if_needed 2023-09-29T04:25:20 [INFO] 0 unhandled notification LogMessage: { "level": 0, "message": "[DEBUG] [agent] [2023-09-29T04:25:20.851Z] Agent service starting", "metadataStr": "[DEBUG] [agent] [2023-09-29T04:25:20.851Z]", "extra": [ "Agent service starting" ] } 2023-09-29T04:25:20 [INFO] 0 unhandled notification client/registerCapability: { "registrations": [ { "id": "5e6efcb2-46d3-4663-9fff-f6380eafe61e", "method": "workspace/didChangeWorkspaceFolders", "registerOptions": {} } ] } 2023-09-29T04:25:20 [INFO] 0 unhandled notification LogMessage: { "level": 0, "message": "[DEBUG] [agent] [2023-09-29T04:25:20.860Z] Telemetry initialized", "metadataStr": "[DEBUG] [agent] [2023-09-29T04:25:20.860Z]", "extra": [ "Telemetry initialized" ] } 2023-09-29T04:25:23 [INFO] Opening main db 2023-09-29T04:25:23 [INFO] starting language server "next-ls", path: "/Users/mitchell/src/btcticker", id: 1 2023-09-29T04:25:28 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:28 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:28 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:28 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:28 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:29 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:29 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:29 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:31 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:31 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:32 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:33 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:34 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:35 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:35 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:35 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:35 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:35 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:35 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:35 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:35 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:35 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:35 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:25:36 [ERROR] error reading file on event No such file or directory (os error 2) 2023-09-29T04:26:34 [ERROR] unexpected item event after pane was dropped 2023-09-29T04:27:08 [ERROR] unexpected item event after pane was dropped 2023-09-29T04:27:36 [ERROR] unexpected item event after pane was dropped 2023-09-29T04:28:02 [INFO] open paths ["/Users/mitchell/.config/zed/keymap.json"] 2023-09-29T04:28:02 [INFO] starting language server "json-language-server", path: "/Users/mitchell/.config/zed/keymap.json", id: 2 2023-09-29T04:28:02 [INFO] Node runtime install_if_needed 2023-09-29T04:28:04 [INFO] Node runtime install_if_needed 2023-09-29T04:28:04 [ERROR] unexpected item event after pane was dropped 2023-09-29T04:28:04 [ERROR] crates/project/src/project.rs:2822: no worktree found for diagnostics path "/Users/mitchell/.config/zed/keymap.json" 2023-09-29T04:28:07 [WARN] request completed with error: request or operation took longer than the configured timeout time 2023-09-29T04:28:07 [ERROR] request or operation took longer than the configured timeout time

Caused by: [28] Timeout was reached 2023-09-29T04:30:53 [ERROR] unexpected item event after pane was dropped 2023-09-29T04:33:15 [WARN] request completed with error: request or operation took longer than the configured timeout time 2023-09-29T04:33:15 [ERROR] request or operation took longer than the configured timeout time

Caused by: [28] Timeout was reached

mikayla-maki commented 1 year ago

This should be fixed in v0.106.2 :)

mhanberg commented 1 year ago

Thank you!