Remove Cache when non-existing file or file outside of workspace gets closed #1010
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.
Currently caches for all files are kept forever (inside
State
).That's ok, but in certain situations unnecessary and we can safely remove caches:
It's nice to slightly reduce memory footprint for long sessions, but also fixes following cases:
VSCode shows old diags for a new untitled file with same name (even when language not set to F# in new untitled file...) -> clearing cache (or more precise: clearing diags) removes old diags
Ctrl+N
) (->Untitled-1
if it's the only untitled doc)F#
(-> F# script file)let foo = bar
-> error "The value or constructor 'bar' is not defined."Untitled-1
))Iterating over all projects and their source files in
State
contains closed non-existing files (like untitled files) and external files -> not something to consider when doing something in FSAC, but are currently insideState
.But I'm looking into "Find all references" -> Sometimes want to find in all files -> iterate over all projects & their files. But this contains obsolete files too
This PR removes non-existing files and files outside workspace when they get closed (
textDocument/didClose
Notification) -> removed from State & diags get cleared for that file.Some issues:
State
when atextDocument/didChange
notification is still processed whentextDocument/DidClose
comes inState
the file is still part of a project and requires a restart to revaluate.