Skip to content

fix: out of date diagnostics after closing and re-opening a file #851

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

Merged
merged 2 commits into from
Jan 12, 2024

Conversation

rchl
Copy link
Member

@rchl rchl commented Jan 12, 2024

diagnostics would malfunction for a file that was closed and later re-opened

@github-actions github-actions bot added the fix label Jan 12, 2024
Copy link
Contributor

github-actions bot commented Jan 12, 2024

size-limit report 📦

Path Size
lib/cli.mjs 778.53 KB (+0.01% 🔺)

Copy link
Contributor

@predragnikolic predragnikolic left a comment

Choose a reason for hiding this comment

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

Works great!

@rchl rchl merged commit f395cd6 into master Jan 12, 2024
@rchl rchl deleted the fix/diagnostics-update branch January 12, 2024 20:42
@predragnikolic
Copy link
Contributor

I just read the LSP spec,
and I think that we should just be aware what the spec says:

https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_publishDiagnostics

  • 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).

TS server belongs to the list of languages that has projects, so I think this PR might affect to sometimes clear diagnostics when it shouldn't.

As I said, I want us to be aware of what the spec says.
This PR brings the behavior of how VS Code behaves and fixes one issue.

@rchl
Copy link
Member Author

rchl commented Jan 25, 2024

This server doesn't provide diagnostics for all project files so the second case doesn't apply to it and it would be wrong to not clear file diagnostics on closing the file then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants