[ty] Fix bug where diagnostics could disappear after opening an external file#23447
Merged
BurntSushi merged 1 commit intomainfrom Feb 20, 2026
Merged
[ty] Fix bug where diagnostics could disappear after opening an external file#23447BurntSushi merged 1 commit intomainfrom
BurntSushi merged 1 commit intomainfrom
Conversation
…nal file This happened whenever: * Diagnostic mode was set to `openFilesOnly` * One opened and then closed an external file (or caused the LSP client to send notifications that a file was closed, which may happen even when the end user doesn't actually open or close a file) When this happened, the entire open file set was cleared. This in turn resulted in `should_check_file` returning `false` for any file previously in the open file set. And thus, we'd never get any diagnostics. Looking at our revision history, it seems like this bug has been present for a long time? I'm not sure. However, this bug doesn't apply when the diagnostic mode is set to `workspace`, which might explain why it defied reproduction. I've also included a regression test and some extra TRACE level logs that might help diagnose these sorts of problems in the future. Fixes astral-sh/ty-vscode#342
Typing conformance resultsNo changes detected ✅ |
Memory usage reportMemory usage unchanged ✅ |
|
dhruvmanila
approved these changes
Feb 20, 2026
Member
dhruvmanila
left a comment
There was a problem hiding this comment.
Uff, that looks quite hard to find, thanks for adding the trace logs!
Do you have a sense on how this would affect when invoked via CLI?
Member
Author
I do not. I don't think |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This happened whenever:
openFilesOnlyLSP client to send notifications that a file was closed, which
may happen even when the end user doesn't actually open or close
a file)
When this happened, the entire open file set was cleared. This in turn
resulted in
should_check_filereturningfalsefor any filepreviously in the open file set. And thus, we'd never get any
diagnostics.
Looking at our revision history, it seems like this bug has been
present for a long time? I'm not sure. However, this bug doesn't apply
when the diagnostic mode is set to
workspace, which might explainwhy it defied reproduction.
I've also included a regression test and some extra TRACE level logs
that might help diagnose these sorts of problems in the future.
Fixes astral-sh/ty-vscode#342