Fix another case of outdated diagnostics #2654
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Somehow I still keep running into outdated diagnostics ;) I've identified one more problem.
When the response for pull diagnostic comes back, in
SessionBuffer._on_document_diagnostic_asynctheversioncan be 5 (for example) but by the time the code gets toSessionBuffer.on_diagnostics_asynctheview.change_count()can increase. Since we didn't pass the actual diagnosticsversiontoSessionBuffer.on_diagnostics_async, we assumed that those diagnostics are for the latest version of the view (6 in this example) and then never requested the more recent diagnostics (actual version 6 diagnostics) later. Fix by passing the actual version of the diagnostics around so that we never show outdated diagnostics due to not getting latest diagnostics.Also reset
_diagnostics_versionon diagnostics request getting canceled. This might not make any difference in practice since if we did cancel the request then it likely means that the view version has changed and we wouldn't ignore next request anyway but in any case, this change feels right.