-
-
Notifications
You must be signed in to change notification settings - Fork 390
User a looser comparison to match Diagnostic
objects
#4051
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
User a looser comparison to match Diagnostic
objects
#4051
Conversation
Discovered while investigating issue haskell#3857. Technically, there are only two required fields in an incoming `Diagnostic` object: `range` and `message`. However, the HLS was comparing all fields to determine equality. This caused mismatches when neovim stopped sending the (optional) `tags` field.
I think I'm still not quite following. Diagnostics come from the server, not the client. So I think what must be happening is:
If that's so, I think there are several things going on:
If you like, you could try implementing my suggestion about filtering based on range instead of the diagnostics. I think that would be both simpler and more robust. For one thing, there is really no guarantee that clients even send the |
It works for me. (I reported the original issue.) Thank you!! |
Looking at the spec more closely, I see the |
Re: How things are now: I definitely agree, it's a little strange. And more importantly, it seems quite brittle. That said, after doing some spot-checking of other HLS plugins, it seems like they're doing very similar operations. (i.e. doing a loose check of specific fields of the incoming If there are larger questions at play of how code actions should work (in HLS or more generally), it might still be worth merging this change or something like it to un-break the feature in the meantime. (I really felt the pain when removing all these unused imports manually, for example 😅 .) Re: How things should be: Couple observations based on my limited understanding (of HLS, LSP, and Haskell, haha):
Jeez, this kinda turned into an essay, heh. Apologies! |
Oh awesome, I just saw they pushed a fix on the neovim side too! 🎉 |
Since the issue is hopefully fixed on the neovim side and doesn't present elsewhere, I'm inclined to skip the local fix. I've made #4056 to discuss the broader issue. I very much agree that our current handling is dodgy, hopefully we can figure out how we should be doing it and do that instead. |
Makes sense to me! As long as the "remove all" feature comes back to life, I'm happy. I'm all for not merging a "temporary" fix if there's another path forward. I'll close this PR but leave the branch around, at least until the next version of neovim is cut, just as a potential workaround for folks who might need it. (I assume it's easier for most HLS users to build HLS than neovim.)
Excellent! Subscribing with interest to the new issue 😄 Thanks! |
This fixes #3857, and makes "remove all redundant imports" code action work again in neovim.
However, I don't know at all if this is an appropriate fix! Opening the PR anyway to start the discussion. (And also so people can build HLS from this branch manually, if they want, to work around an annoying bug.)
The root cause of this was neovim no longer sending the
tags
field in theirDiagnostic
objects. (See neovim/neovim#27318.) This was causing a lookup to be missed here.However, it appears that according to the LSP docs, that's not a required field. And in fact, only
message
andrange
are required.My fix is very local. If this issue exists in other plugins or other code actions, this will not affect them. (For better or worse.) Also, I don't know if there are better patterns to do this kind of thing in Haskell generally...
Like I said, just opening this to start the discussion. So... discuss! 😄