-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript Language Sever crashes on 'Move to a new file` #2029
Comments
I've seen this pop up in odd scenarios in elixir-ls but haven't had the time to make a nice reproduction case. My understanding is that the language server is breaking the spec by sending
Though helix should probably not be panicking: it would make sense to discard a message from the language server that cannot be correctly decoded and log it as an error. |
@the-mikedavis I think this is the issue you are talking about is:
https://github.com/jose-elias-alvarez/nvim-lsp-ts-utils which links to neovim/neovim#14469 Also, there is a new Neovim plugin that attempts to fix and enhance the TypeScript Language Server (for Neovim, and probably any client that is not VS Code): https://github.com/jose-elias-alvarez/typescript.nvim Is it possible to port the fix? |
Here's the spec on ranges that says they must be 0-based: https://microsoft.github.io/language-server-protocol/specification#range If I'm reading this right, here's the fix in that plugin: jose-elias-alvarez/nvim-lsp-ts-utils@d21761d#diff-1aff290f09c6b3579514b767764dbe457f42b96b9425b888c9f7e3ba8b2121b7R214-R219. It just sets it to On the one hand it seems like an easy fix to make but on the other hand this is a pretty blatant violation of the LSP spec. I can't find any issues in the typescript LS repo about negative ranges. Maybe it hasn't been reported yet? |
It's at the Position description:
|
For elixir-ls looks like this is a quick fix: diff --git a/apps/language_server/lib/language_server/build.ex b/apps/language_server/lib/language_server/build.ex
index e8d050c..1d6a441 100644
--- a/apps/language_server/lib/language_server/build.ex
+++ b/apps/language_server/lib/language_server/build.ex
@@ -279,7 +279,7 @@ defmodule ElixirLS.LanguageServer.Build do
end
defp range(position, nil) when is_integer(position) do
- line = position - 1
+ line = if position - 1 < 0, do: 0, else: position - 1
# we don't care about utf16 positions here as we send 0
%{
@@ -289,7 +289,7 @@ defmodule ElixirLS.LanguageServer.Build do
end
defp range(position, source_file) when is_integer(position) do
- line = position - 1
+ line = if position - 1 < 0, do: 0, else: position - 1
text = Enum.at(SourceFile.lines(source_file), line) || ""
start_idx = String.length(text) - String.length(String.trim_leading(text)) + 1 I've had elixir-ls crash helix just while sitting at an open file. I'll test more and then open a PR to elixir-lsp/elixir-ls. |
Closed by 7ae6cad Malformed LSP messages are now logged as an error and discarded instead of panicing. |
Summary
When a code action 'Move to a new file` is available, if selected it crashes with:
Reproduction Steps
example.ts
place cursor on
example
, pressspace a
and 'Move to a new file'Maybe this feature is not built in yet, or maybe it is a bug?
Helix log
~/.cache/helix/helix.log
Platform
Linux
Terminal Emulator
Kitty
Helix Version
helix 22.05-dev (2d4f94e)
The text was updated successfully, but these errors were encountered: