fix: clear stale custom editor model entry on rejection#304815
Open
yogeshwaran-c wants to merge 2 commits intomicrosoft:mainfrom
Open
fix: clear stale custom editor model entry on rejection#304815yogeshwaran-c wants to merge 2 commits intomicrosoft:mainfrom
yogeshwaran-c wants to merge 2 commits intomicrosoft:mainfrom
Conversation
When removing manual folding ranges with an empty selection (cursor only), find and remove only the innermost manual folding range containing the cursor, rather than all manual ranges that intersect with the cursor line. This allows users to precisely remove a specific manual range without losing outer manual ranges in a nested hierarchy. For non-empty selections, the existing behavior of removing all manual ranges intersecting the selection is preserved. Closes microsoft#212599
When a custom editor model promise rejects (e.g., because the file was not found), the rejected promise remains cached in the model manager's reference map. On subsequent attempts to open the same custom editor, tryRetain returns the same rejected promise, causing the editor to always show the original error even if the underlying file now exists. Fix by attaching a catch handler that removes the entry from the references map when the model promise rejects. This allows the next open attempt to create a fresh model. Fixes microsoft#268301
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.
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
When a custom text editor fails to open because the backing file doesn't exist (e.g., the file URI is passed to
vscode.openbefore the file is created), the model promise is stored inCustomEditorModelManager._referencesin a rejected state. On subsequent attempts to reopen the same custom editor (even after the file is created),tryRetain()returns the same rejected promise, causing the editor to perpetually show "The editor could not be opened because the file was not found." — even clicking "Try Again" doesn't help.Closes #268301
What is the new behavior?
When a model promise rejects, the entry is automatically removed from the references map via a
.catch()handler. This allows the next attempt to open the custom editor to create a fresh model, which will succeed if the file now exists.Additional context
The fix adds a
.catch()handler in theadd()method that cleans up the rejected entry from_references. This is safe because:.catch()only fires on rejection, so successful models are unaffecteddisposeAllModelsForViewor thetryRetaindispose callback,Map.deleteis a no-optryRetainwill naturally decrement when callers handle the rejection