-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
check for duplicate diagnostics before adding new one #282
base: main
Are you sure you want to change the base?
check for duplicate diagnostics before adding new one #282
Conversation
I guess this only really fixes the symptoms, but I wonder why they show up multiple times in the first place. It seems like there's another issue somewhere deeper in the stack |
This might still be worthwhile to add, nonetheless |
Hmm okay if you think so. You are right though, I hesitated before opening this PR because i realise it only fixes the sypmtom. My initial theory was the |
The issue is here: stimulus-lsp/server/src/diagnostics.ts Line 324 in 93fdd53
Since the linked issue is importing two exports we also have two "import declarations" in the array, one for each import, thus resulting in the 4 diagnostics. import { Controller, Context } from "stimulus" But I'm not sure why we see 4 in that case and not just two. |
@marcoroth okay, so I may have found the bug. There are two locations from where This causes two diagnostics to be added.
Here is a similar discussion of the issue: microsoft/vscode-discussions#511 What do you think we should do? imo we remove the EDIT - however, I'm not sure if this would work if the LSP is used outside of VScode e.g Neovim etc. |
okay upon further investigation, the issue does not lie in what I previously thought^ I am quite certain It is this event and the usage that is causing the issue: stimulus-lsp/server/src/server.ts Lines 102 to 108 in 27a7283
the service.refresh() call is adding multiple diagnostics.
|
Oh interesting, thanks for the investigation @nachiket87! After thinking about this a bit more, it feels like this diagnostic should anyway be part of the Stimulus Parser itself and not part of the LSP. So maybe if we move the analysis to the parser we could solve the issue that way, would that make sense in your eyes? |
Sure! I've been looking at the stimulus parser for this and at the moment I have no idea how I would implement it. I will continue trying though and let you know how it goes. |
Hey @nachiket87, FWIW, I still think this could be useful to add. |
Really @marcoroth ? okay, do you have any feedback on this? Sorry I didn't come back to this. |
I don't have any feedback right now, I just wanted to try to find the root cause and fix it and then merge this one |
possible fix #275
Alternatively, I tried checking if
service.refresh()
was called multiple times unnecessarily but that was not the case.