Fix handling of unchanged diagnostics report - #3012
Conversation
| if diagnostics is not None: | ||
| # `None` means we received an UnchangedDocumentDiagnosticReport, in which case we still have to redraw | ||
| # diagnostic regions in the view to maintain the original positions. | ||
| self.diagnostics.set_diagnostics(uri, identifier, diagnostics) | ||
| mgr.on_diagnostics_updated() |
There was a problem hiding this comment.
I'm coming here without refreshing my memory on how diagnostics rendering works but just reading that comment makes me a bit confused because it talks about still having to handle the None case but being inside the !None branch. Is it misplaced?
There was a problem hiding this comment.
Yeah maybe it's a bit misplaced, I think I put it here because these two lines are the only part of this method which is affected by diagnostics being None or not None. And there is no else branch. I could put the comment after this if-block, if that makes it clearer?
There was a problem hiding this comment.
Done in fed82d0 and tried to make the wording a bit more clear.
✅ Deploy Preview for sublime-lsp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
I noticed that UnchangedDocumentDiagnosticReport is not handled correctly. Unchanged diagnostics report means that the previous diagnostics (and as far as I understand, including the diagnostic's
range) are still accurate. Currently we do "nothing" when we receive such a report:LSP/plugin/session_buffer.py
Lines 674 to 676 in bef834e
But actually we need to redraw diagnostics regions in the view, because diagnostics are typically requested after a buffer change, and ST automatically adjusts/shifts existing region decorations if lines before the region we removed or added, or characters were inserted or removed on the same line before the region.
If lines or characters were inserted or removed after the diagnostics regions it didn't matter, because in that case the drawn regions are not affected anyway.
I added another
Nonevalue as possible argument toSession.handle_diagnostics_async, which means that we received unchanged diagnostics, i.e. stored diagnostics don't need to be updated, but we still need to trigger a redraw.