Skip to content

Conversation

AdrienBoulanger
Copy link
Contributor

We were sending diagnostics after the document was already closed,
at this point this is the responsability of the client to free
the diagnostics (without receiving an empty list).

@AdrienBoulanger AdrienBoulanger force-pushed the topic/U922-018.diagnostics.on_close branch from ff7794b to b4ed8b8 Compare September 22, 2021 15:17
We were sending diagnostics after the document was already closed, at this point this is the responsability of the client to free the diagnostics (without receiving an empty list). Adapt tests.
@AdrienBoulanger AdrienBoulanger force-pushed the topic/U922-018.diagnostics.on_close branch from b4ed8b8 to 8edad93 Compare September 22, 2021 15:26
Copy link
Member

@reznikmm reznikmm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point this is the responsability of the client

No, LSP doesn't work this way. According to specification:

Diagnostics are “owned” by the server so it is the server’s responsibility to clear them if necessary. The following rule is used for VS Code servers that generate diagnostics:

  • if a language is single file only (for example HTML) then diagnostics are cleared by the server when the file is closed. Please note that open / close events don’t necessarily reflect what the user sees in the user interface. These events are ownership events. So with the current version of the specification it is possible that problems are not cleared although the file is not visible in the user interface since the client has not closed the file yet.
  • if a language has a project system (for example C#) diagnostics are not cleared when a file closes. When a project is opened all diagnostics for all files are recomputed (or read from a cache).

Currently we implement the first approach, because it simpler. If we want to switch to the second, we should

  • clear diagnostics if project changed
  • still clear diagnostics for an out-of-project file on closing it, because otherwise diagnostics stay forever on the client site.
@AdrienBoulanger AdrienBoulanger deleted the topic/U922-018.diagnostics.on_close branch September 28, 2021 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants