Repository navigation
customEditor: fix stale cache after file deletion - #287966
Merged
Matt Bierner (mjbvz) merged 3 commits intoJul 27, 2026
Merged
Matt Bierner (mjbvz) merged 3 commits into
Matt Bierner (mjbvz) merged 3 commits into
Conversation
When files are deleted via the VS Code fs API, the custom editor model manager was not cleaning up its cached references. This caused issues where recreating a file with the same name would result in "file not found" errors in the custom editor, even though the file exists. The fix adds a handler for FileOperation.DELETE in CustomEditorService that disposes all models associated with the deleted resource, ensuring the cache is properly invalidated.
Matt Bierner (mjbvz)
approved these changes
Mar 27, 2026
Contributor
|
Thanks! General approach lgtm |
Matt Bierner (mjbvz)
enabled auto-merge
March 27, 2026 07:33
João Moreno (joaomoreno)
approved these changes
Mar 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes stale custom-editor models after resource deletion.
Changes:
- Evicts models when files are deleted.
- Adds resource-based model disposal to the manager API.
Show a summary per file
| File | Description |
|---|---|
customEditors.ts |
Handles delete operations. |
customEditor.ts |
Extends the model-manager interface. |
customEditorModelManager.ts |
Removes models for deleted resources. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Medium
Dmitriy Vasyura (dmitrivMS)
approved these changes
Jul 27, 2026
Dileep Yavanmandha (dileepyavan)
approved these changes
Jul 27, 2026
Don Jayamanne (DonJayamanne)
approved these changes
Jul 27, 2026
This was referenced Jul 30, 2026
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.
Ran into a weird bug where after deleting a file that was open in a custom editor (using the fs API), I couldn't open a new file with the same name - kept getting "file not found" even though the file existed.
Turns out the custom editor model manager wasn't cleaning up its cache when files got deleted. So when you create a new file with the same name, it would find the old cached model reference pointing to a resource that no longer exists.
The fix hooks into the existing file operation handler (which already handles moves) and adds a delete case that disposes all models associated with the deleted resource. Pretty straightforward and follows the same pattern as the existing move handling.
I tested this using the repro from the issue (https://github.com/Greglar4/vscodeBugExampleRepository) and it works - delete a file, recreate it with the same name, and the custom editor opens it correctly now.
Fixes #278883