-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Yet More Erratic / Broken Behaviour #878
Comments
This does not happen right after init does it? |
@razzeee It does seem to happen when opening, but it also recurs when editing the file. |
This happens for me in vscode quite often, and it seems to disappear upon saving changes (maybe). |
I am trying helix to see if there is better lsp experience than with emacs, but I also constantly get random whole page errors. Screen.Recording.2023-03-06.at.18.20.11.mov |
I get this in helix. Also in helix the language server has some kind of problem where it can take 10 or 20 seconds to save a file. :lsp-restart sometimes fixes it. I have to :lsp-restart every 10 mins or so to get definition lookup and etc. |
@bburdette The issue with saving hanging for a few seconds, seems to be because of LS response times for formatting.
My LS experience in helix is significantly better than with emacs, but definitely far from ideal. I too have to restart the LS constantly. |
Doing formatting like that should lead to your cursor getting displaced in some situations. Let me try to do a release this weekend, there were some interesting sounding fixes upstream |
Just upgraded elm-language-server to 2.7.0, and so far its quite a bit better. The pervasive parsing problems are gone, and so are the problems with the e.l.s. hanging. 👍👍 |
I still get these "whole file is covered with error(s)" with 2.7.0 and in emacs. |
Hi, I'm also running into this issue quite often and would like to offer my help investigating it, if I can. I would say I can reproduce this very consistently in my project(s). I'm using Helix, elm-language-server v2.7.0, and elm-format v0.8.7 - both packages installed from nixpkgs, in case that matters. What I've observed so far is that it definitely seems related to formatting, at least for me:
:lsp-restart in Helix consistently fixes the issue, until I make another change and trigger it by formatting again - so it doesn't happen for me on init. My impression is that this happens more often when there is an actual error present, e.g. I try calling a function that doesn't exist. However, in my testing I have seen it happen when all my changes were valid as well. @razzeee As I said, I can reproduce this pretty consistently. Is there anything I can do to help figure this issue out? Any hints you can give me for a next step? Side noteThe problem seems to occur even when I configure Helix to use elm-format directly. E.g. my language configuration for Helix contains:
What this accomplishes is that Helix will call elm-format directly to auto-format the document, instead of sending a format-request to the LSP. At least I think it does... |
I don't know how helix works, but there should be a way to get a log with an edit history. I would think that that history shows a bug. |
TL;DR: I think there might be a bug in how the language server updates the AST when the client sends multiple I think I might have found something... First of, here's a recording of the change I'm making to reproduce the behavior: https://asciinema.org/a/BQKxoJq52G3NIxH4YOW7Yxavw Now, in the helix logs I can see the messages being sent to the LSP and the replies the editor gets. As you can (hopefully) see in the recording, there are two changes being made on format - the assignment being broken up into two lines and the newline between let-expression and function body being removed. So, the response to the formatting request looks like this:
In turn, the editor applies theses changes and reports back with a
I noticed that for the second change, the line number differs between the formatting response and the next didChange request, so I started wondering about that. This is in line with the spec, however:
Is it possible, that the elm language server does not handle this scenario correctly? I.e. to me it looks like the language server might apply both changes to the same initial state S, and therefore assuming the second edit at a wrong line. This would make a lot of sense to me. It would, for example, explain why it only happens on formatting the document. During normal editing of the document, Helix (and I assume other editors as well) sends each individual key stroke as a I suspect the issue is with this loop, however, I don't know enough about the language server code and tree-sitter to say for sure. What exactly does Could one of the maintainers please confirm, whether my analysis sounds correct? 🙏 |
It would also explain why:
|
Ok, after some further investigation I'm fairly sure I understand what is happening. The issue, I think, is indeed related to the client sending multiple This call to I've attempted a (very hacky) solution and it solved the issue for some specific change sets (e.g. the one I was demonstrating earlier), but I could still get the language server into a bad state, so it's not ready yet. It also basically amounted to trying to count the number of newlines being added and removed in previous changes and accounting for that in the calculation in I might have some more time to look into this on the weekend, but if anyone who's more knowledgeable about the code base than me wants to take over, that'd be great as well 😃 |
So I guess the question is if In https://github.com/elm-tooling/elm-language-server/blob/main/src/common/providers/astProvider.ts#L112 and https://github.com/elm-tooling/elm-language-server/blob/main/src/common/providers/astProvider.ts#L114 Should be "easy" to print it and figure it out. I'm however still confused, why this doesn't seem to happen with vscode. FYI @jmbockhorst |
Yes, sorry for not being clearer, that is exactly what I did during my investigation and it does indeed pass the same text for all invocations of As to why it doesn't happen in VSCode, I don't have an answer yet. First of, I thought it was also happening in VSCode? 😅 My wildest guess would be that VSCode does not group contentChanges in one notification, even if there are multiple changes from the formatter. That would be pretty weird though, and I don't have the means to check that right now. |
Hey! I linked a PR that I think will fix the erratic behavior and parsing errors. The code is pretty much lifted from the typescript-language-server. The idea is basically just to keep track of the changed text for each "intermediate" state ourselves, since I have tested this only a little and could not reproduce any of the issues that I could before. I'll try to put in a real Elm coding session soon, to test-drive my PR under more realistic conditions :) Edit: I've been using elm-language-server with my changes for the past two days and haven't had any more issues with bogus parsing errors :D |
Please try the new builds |
Giving this a try today. After about 30 mins of usage no problems, which is definitely out of the ordinary. Did seem to get a bit tweaked on :lsp-restart. But after restart of helix, back to normal and seems to stay that way. Will update if I run in to issues. |
When using elm-language-server version
2.6.0
in neovim, both with COC and with native LSP support, the project will randomly be covered in errors. Other times (more frequently), nearly every top level definition (includingmain
) is flagged with anUnused pattern variable
warning. Typing in or saving the file seems to randomly both induce and relieve this issue, and its occurrence seems to be more frequent on larger projects.I've attached two screenshots, the first with COC and the second with the native LSP. In addition, the actual installation of elm-language-server varied between the two (the first done globally on my system through npm, the second handled by mason), so it's unlikely that was the root cause.
This is in a project that compiles and runs without error:
As this seemed similar to #503 and #598 I tried all proposed solutions there, none seeming to work. Sorry for this being a bit vague, if there's more specific information that would be helpful please let me know how to provide it!
Cheers
The text was updated successfully, but these errors were encountered: