Skip to content

Reporting unchanged result for newly closed file in workspace diagnostics causes stale diagnostics #1673

@dibarbet

Description

@dibarbet

Reporting an unchanged result from workspace diagnostics for a newly closed file causes the problems list to show stale diagnostics. Not 100% sure if this is a client side bug, or if the server needs to do something else to better handle this scenario.

This seems to be the cause of dotnet/vscode-csharp#8355 - we clear diagnostics when a text document is closed and expect workspace diagnostics to re-report them. But when we report unchanged (based on the resultId we were given), the workspace diagnostics associated with that resultId are not shown.

It's a little complicated, so hopefully the repro steps make it clearer.

Repro steps

See the gif which runs through the steps below.

  1. Clone and open the lsp-sample on this branch, F5 and open the testWorkspace folder in the dev instance
  2. If a text file is not opened, open one. The server reports 1 changed document result (open file) and 1 changed workspace result (closed file)
  3. Close the file. The server reports 2 workspace reports for the 2 closed files (one changed, one unchanged), and the problems window shows both.
  4. Open the same file, server reports 1 changed document report and 1 unchanged workspace report.
  5. Close the file again. Client requests workspace diagnostics, passing in resultIds for both reports from step 3). Server reports 2 unchanged workspace since diagnostics have not changed. Note the errors in the problems list do not match what was reported in 3).

Image

Expected

The server reported two unchanged workspace reports, one for each file now that the file is closed. Problems list should show the workspace reports.

Actual

Problems list still shows the document report for the now closed file, even though the server reported workspace diagnostics for it.
Image

As mentioned above, if the server ignores the client resultId and reports it as changed, then the problems list is correctly updated to show the workspace diagnostic result for both.

Seems like either

  1. If the client is going to send the previous workspace report resultId (from before the document was opened) to the server, it needs to remember what diagnostics were associated with that report and put them back
  2. Or do not send the previous resultId on re-opening so that the server re-reports them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions