-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: initial diagnostic run "overwrites" subsequent file-open diagnostics #36452
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
Comments
For the record we've just seen another instance in:
Log file:
|
The version 0 diagnostics being published too late is likely unrelated, but definitely the first obvious issue. Let me send out a CL to address this and then maybe you can let me know what that changes. |
Change https://golang.org/cl/213820 mentions this issue: |
I think the suggested fixes issue is coming from
I would imagine that https://golang.org/cl/213820 will fix this, but it shouldn't be necessary (and I'm not yet convinced that it should go in, I'll wait for @heschik's thoughts there). This seems like a |
Ah that's an excellent spot, thank you. We'll fix up diagnostics handling on our side to drop/error anything that isn't a higher version (for a given file) than before. Will also test out with that CL when it lands. |
Per #36476 (comment) we have fixed things on the Whilst we're happy having a safety net in |
I actually disagree with this point:
It's on the client to know the current version of the file in the editor and to understand that the diagnostics for a different version do not apply. |
This isn't a strictly necessary change, but it simplifies things for open files when the initial workspace load diagnostics come in too late. Updates golang/go#36452 Change-Id: I85a9c201876b7c63a97d8dca020fc396b3c57706 Reviewed-on: https://go-review.googlesource.com/c/tools/+/213820 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
Closing this as https://golang.org/cl/213820/ has been merged. |
Thanks for the fix. Just to briefly clarify what I meant earlier (it's only a minor point):
Indeed, and we do perform this check. Without this check many things could/would go wrong because of races between the user making changes and diagnostics being "applied" (formatting etc) What I was referring to here is another check that we just inserted to (silently) drop non-new diagnostics. It's this check that I think should be superfluous. Clients should, to my mind, be able to assert that they will only ever receive new diagnostics for a given file. |
Change https://golang.org/cl/214418 mentions this issue: |
What version of Go are you using (
go version
)?Note the
replace
-d version ofx/tools
andgopls
. Per govim/govim@afa4918, we are in effect using 53017a3 with 11e9d9c cherry-picked on top.Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
We have a
govim
test that verifies suggested fixes. The initial setup is:We then ask for suggested fixes via a
CodeAction
call and apply the single fix that should be returned.What did you expect to see?
A single fix returned.
What did you see instead?
No fixes returned.
The gopls log: gopls.log looks somewhat interesting. It has, at a high level, the following order:
client -> server
:DidOpen
formain.go
- version 1client -> server
:DidChange
formain.go
- version 2client -> server
:DidChange
formain.go
- version 3server -> client
:PublishDiagnostics
for version 3. Diagnostics are a single analysis warning diagnostic about self assignmentserver -> client
:PublishDiagnostics
for version 0. No diagnosticsclient -> server
:CodeAction
call for suggested fixes in the range of the self assignmentWe get back no results from that last call.
The diagnostics being published for version 0 appears to be an issue in and of itself (arguably the client could ignore these but
gopls
should not be publishing them) but it also appears to suggest that the diagnostics including the analysis results (version 3) are being "overwritten", hence why theCodeAction
call returns nothing.cc @stamblerre
FYI @leitzler
The text was updated successfully, but these errors were encountered: