-
Notifications
You must be signed in to change notification settings - Fork 459
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
fix: Clear Diagnostics when file is closed #1591
fix: Clear Diagnostics when file is closed #1591
Conversation
…owing up as "problems" in VS code. fix: LSP when file is closed clear any diagnostics so the "problems" list is cleared in VS code. Note: if we want "project" level errors we should implement the full PublishDiagnostics LSP protocol, specifically the part about if a language has a project system (for example C#) diagnostics are not cleared when a file closes. When a project is opened all diagnostics for all files are recomputed (or read from a cache
Thanks for your contribution! Please make sure to follow our Commit Convention. |
My five cents: there are two unrelated changes here. The change that clears diagnostics when the file worker exits seems for the better. Leftover diagnostics are often noisy and out-of-date. Indeed computing them for an entire Lake project as you write would be ideal, but short of that we should do the clearing. On the other hand the information -> hint change is likely to be controversial (many users including myself are quite used to the info squiggles) — I am not sure it is the right move. I'd happily approve the PR if it were just the first of the two changes. |
Ok, I split the more controversial change out to separate PR: |
Should this be moved into the watchdog instead? Sending a response after receiving |
I saw the "exit" event as an ideal place to do it, just before the process terminates it sends the message. I don't see why that would create a deadlock, at worst it would mean some test doesn't see the messages get cleared ? But it seemed very reliable in VS code when I was opening and closing files manually. I suppose I could design a torture test to see if I can force it to break... |
Hm, I missed the test failures. @lovettchris could you try clearing the diagnostics in the watchdog after sending the |
I see, the problem was in the test harness | Message.request id "shutdown" _ =>
st.hOut.writeLspResponse ⟨id, Json.null⟩
shutdown so that the ResponseId is always sent first. The tests should pass now. |
I am not sure this is the right thing to do here. Note that from the watchdog's perspective, sending a response to the shutdown request means "we are ready to exit (i.e. kill the process)". But we are not ready to exit before the |
So it's not just an 'ack' that shutdown was received? I could fix it by changing the test to expect the new diagnostics message before the ack on the shutdown... |
I pushed this change, so |
@lovettchris the changes to the tests look good. It is legitimate for the server to send more messages after receiving the On the other hand I am still not sure about the clearing of diagnostics after receiving |
Ok, I moved it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, lgtm! We'll see in practice if all editors are happy with this change.
…lways the last thing sent after document close.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the stray changes
Done. |
fix: LSP when file is closed clear any diagnostics so the "problems" list is cleared in VS code.
Note: if we want "project" level errors we should implement the full PublishDiagnostics LSP protocol, specifically the part about if a language has a project system (for example C#) diagnostics are not cleared when a file closes. When a project is opened all diagnostics for all files are recomputed (or read from a cache), etc. I think we should implement this for lean lake projects, but it's a much bigger change.