-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: cache diagnostics, don't re-send if unchanged #32443
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
|
This helps to throttle the number of changes we try to push through to the quickfix window. However, golang/go#32443 remains an issue in as much as incomplete diagnostics are sent to the client. i.e. we can't be sure to receive the most recent diagnostics for the file which we are editing (and in which we know, for example, we are making errors).
This helps to throttle the number of changes we try to push through to the quickfix window. However, golang/go#32443 remains an issue in as much as incomplete diagnostics are sent to the client. i.e. we can't be sure to receive the most recent diagnostics for the file which we are editing (and in which we know, for example, we are making errors).
|
Updated my two previous comments to reflect the fact that diagnostic results from
Hence govim/govim@e9bdd97 fixed this for So this issue is now just about the superfluous diagnostics being sent from |
There is a similar problem in emacs. If there are too many files in a package, when editing one of the files, each time you add a character, you will get the diagnostics of all the files under the package, causing the emacs to be very stuck and almost impossible to edit. |
This is likely one of the causes of #33531. |
Currently, because of golang/go#32443 we can unnecessarily update the quickfix window with diagnostics. What's more, when we update the quickfix list we lose the selected index; the first row is selected when the quickfix list is reset. This presents something of a problem when jumping to a quickfix error in a file that is not currently open, where that error is not the first in the quickfix list. Because jumping to that error means we trigger a didOpen, which triggers all diagnostics to be sent again (even though they haven't changed), which causes the first row to be selected again. The user, understandably, get's very confused. So for now, we use reflect.DeepEqual to de-dupe the diagnostics we receive from gopls, pending a fix to golang/go#32443. We also keep track of the last set error diagnostics, so that when setting new diagnostics we can reselect the currently selected row. Or, if that row no longer exists, select the first row. This changes the times that setqflist is called. Hence, fix up tests which previously asserted based on this behaviour. As part of this change we also retrigger clearing/population of the quickfix list (and signs) as the relevant config changes. Also slightly optimise the sign placement code to return early if signs are disabled.
Currently, because of golang/go#32443 we can unnecessarily update the quickfix window with diagnostics. What's more, when we update the quickfix list we lose the selected index; the first row is selected when the quickfix list is reset. This presents something of a problem when jumping to a quickfix error in a file that is not currently open, where that error is not the first in the quickfix list. Because jumping to that error means we trigger a didOpen, which triggers all diagnostics to be sent again (even though they haven't changed), which causes the first row to be selected again. The user, understandably, get's very confused. So for now, we use reflect.DeepEqual to de-dupe the diagnostics we receive from gopls, pending a fix to golang/go#32443. We also keep track of the last set error diagnostics, so that when setting new diagnostics we can reselect the currently selected row. Or, if that row no longer exists, select the first row. This changes the times that setqflist is called. Hence, fix up tests which previously asserted based on this behaviour. As part of this change we also retrigger clearing/population of the quickfix list (and signs) as the relevant config changes. Also slightly optimise the sign placement code to return early if signs are disabled.
Currently, because of golang/go#32443 we can unnecessarily update the quickfix window with diagnostics. What's more, when we update the quickfix list we lose the selected index; the first row is selected when the quickfix list is reset. This presents something of a problem when jumping to a quickfix error in a file that is not currently open, where that error is not the first in the quickfix list. Because jumping to that error means we trigger a didOpen, which triggers all diagnostics to be sent again (even though they haven't changed), which causes the first row to be selected again. The user, understandably, get's very confused. So for now, we use reflect.DeepEqual to de-dupe the diagnostics we receive from gopls, pending a fix to golang/go#32443. We also keep track of the last set error diagnostics, so that when setting new diagnostics we can reselect the currently selected row. Or, if that row no longer exists, select the first row. This changes the times that setqflist is called. Hence, fix up tests which previously asserted based on this behaviour. As part of this change we also retrigger clearing/population of the quickfix list (and signs) as the relevant config changes. Also slightly optimise the sign placement code to return early if signs are disabled.
Currently, because of golang/go#32443 we can unnecessarily update the quickfix window with diagnostics. What's more, when we update the quickfix list we lose the selected index; the first row is selected when the quickfix list is reset. This presents something of a problem when jumping to a quickfix error in a file that is not currently open, where that error is not the first in the quickfix list. Because jumping to that error means we trigger a didOpen, which triggers all diagnostics to be sent again (even though they haven't changed), which causes the first row to be selected again. The user, understandably, get's very confused. So for now, we use reflect.DeepEqual to de-dupe the diagnostics we receive from gopls, pending a fix to golang/go#32443. We also keep track of the last set error diagnostics, so that when setting new diagnostics we can reselect the currently selected row. Or, if that row no longer exists, select the first row. This changes the times that setqflist is called. Hence, fix up tests which previously asserted based on this behaviour. As part of this change we also retrigger clearing/population of the quickfix list (and signs) as the relevant config changes. Also slightly optimise the sign placement code to return early if signs are disabled.
Currently, because of golang/go#32443 we can unnecessarily update the quickfix window with diagnostics. What's more, when we update the quickfix list we lose the selected index; the first row is selected when the quickfix list is reset. This presents something of a problem when jumping to a quickfix error in a file that is not currently open, where that error is not the first in the quickfix list. Because jumping to that error means we trigger a didOpen, which triggers all diagnostics to be sent again (even though they haven't changed), which causes the first row to be selected again. The user, understandably, get's very confused. So for now, we use reflect.DeepEqual to de-dupe the diagnostics we receive from gopls, pending a fix to golang/go#32443. We also keep track of the last set error diagnostics, so that when setting new diagnostics we can reselect the currently selected row. Or, if that row no longer exists, select the first row. This changes the times that setqflist is called. Hence, fix up tests which previously asserted based on this behaviour. As part of this change we also retrigger clearing/population of the quickfix list (and signs) as the relevant config changes. Also slightly optimise the sign placement code to return early if signs are disabled.
Change https://golang.org/cl/208261 mentions this issue: |
What version of Go are you using (
go version
)?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?
https://github.com/myitcv/govim/blob/multiple_gopls_diagnostics/cmd/govim/testdata/diagnostics.txt defines a test that looks to assert the number of diagnostic callbacks for various files.
The setup is very simple (see the txtar at the end of the script)
The sequence is then:
main1.go
// Hello
What did you expect to see?
As the last two lines of the testscript assert, this should result in:
main1.go
: initial load + first change + second changemain2.go
: initial load (after which no changes are made tomain2.go
or any related file that cause the diagnostics formain2.go
to change)What did you see instead?
main1.go
: initial load + first change + second changemain2.go
: initial load + first change tomain1.go
+ second change tomain1.go
Therefore, two superfluous diagnostic notifications for
main2.go
(because the diagnostics formain2.go
have not changed, i.e. they remain zero.Arguably, there should be no notifications for
main1.go
either because the diagnostics for that file have not changed either, but there may be some requirement on diagnostics being sent for files that have been changed?cc @stamblerre @ianthehat
Edit: update to reflect the fact this problem persists with
golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b
The text was updated successfully, but these errors were encountered: