-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Editor service should not create untitled editors before overrides #106012
Comments
I saw this recently and forgot to follow up: there is an easier repro for this and I think somewhere when custom text editors were added, we forgot to deal with untitled models properly. I think they are not getting freed up. Steps:
=> 🐛 you see |
@lramos15 I think this will be part of your work: with the new override handling moving out of the editor group I think this should be fixed as well because we will no longer create an untitled editor input before the override has happened 👍 |
Optimistically closing. I wasn't able to get the repro steps above to work, but when I create new untitled files with the hex editor the number no longer increments. |
I repro this with the original steps |
Untitled text models typically get created through the I am not sure where in custom editor land untitled files are created. |
It seems like openTextDocument creates a model, and then openWith creates a second one. I fixed properly disposing the openWith model here 9f32d37 (At least I think, I'm not sure if it's expected that the editor input would be disposed in this service). However, I have no way to handle the openTextDocument model disposing as that isn't handled by the editor service flow. Seems like this feature request might cleanup this flow #93441 |
I would argue that it should be the As soon as everyone only uses untyped editor inputs, the lifecycle is a lot clearer and owned only by editor service and editor override service. |
I have renamed the issue. I think #124352 would probably fix this. The gist is that we should stay away from creating |
I think this can be closed? |
I can still reproduce the issue with the original steps. Edit: I've created a repro here https://github.com/microsoft/vscode-extension-samples/tree/rzhao271/106012-repro/custom-editor-sample. |
Ah the steps aren't the same since custom editors don't properly implement the untitled factory yet. I'm not sure the best way to verify this @bpasero but I know it no longer creates the untitled input. |
This should be the steps:
Previously it would be "Untitled-2", indicating that we leaked a typed untitled editor. |
Add a command to the existing custom editor sample extension
{ "command": "catCustoms.catScratch.new", "title": "Create new Cat Scratch Document", "category": "Cat Scratch" }
register command in extension.ts
vscode.commands.registerCommand('catCustoms.catScratch.new', () => { vscode.workspace.openTextDocument({ language: 'catScratch', content: '' }).then(doc => { vscode.commands.executeCommand("vscode.openWith", doc.uri, "catCustoms.catScratch"); }); });
Bug is in step 3, since Untitled-1 was previously closed name should be free for the new untitled file
The text was updated successfully, but these errors were encountered: