-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Let openTextDocument create an untitled file with a specific file extension #93441
Comments
@mjbvz currently the only way that an untitled file allows to configure the file extension to use is either by:
As such, this change also needs to include a way for untitled files to configure a file extension. And I would think that we should then also determine the language mode from such extension if it is not otherwise provided. I can review a PR, I cannot work on this in April though given sandbox duties. |
@mjbvz Did you try |
Custom editors are enabled/disabled based on file names instead of language |
@mjbvz isn't it weird though to call |
@bpasero This does bring up to how to handle custom binary editors however since they do not have a
|
You should be able to use the overload that takes an URI then, this: Lines 8748 to 8766 in d778f85
According to the doc, you call it like so: |
Passing in This maps to the concept of "associated file path" for untitled, e.g. starting |
Slowly understanding what this is about... The proposal has potential for conflict, e.g what should win when language and extension are present. What has come up often, and that might be helpful for this, is to have utilities that map from an extension to a language id (and maybe also the other way around). |
@rebornix we have a similar situation in Notebooks. Our solution:
const fileName = 'untitled-1.ipynb';
const newUri = Uri.file(fileName).with({ scheme: 'untitled', path: fileName });
commands.executeCommands('vscode.openWith', newUri, viewType);
Also, I'm not using the new command
Please note, this isn't a blocker for us, I'm happy with our current solution, however @mjbvz solution does seem better if we could do the same for Notebooks. |
Adding @bpasero as the owner of untitled land |
@mjbvz this issue seems to get snow plowed for a while and I do not see it on the plan. My previous comment still holds true:
Let me know if you want to open a PR for me to review, otherwise I suggest to move this to Backlog. |
Thinking more about this, I feel having this on I would enrich the options you can pass into |
This issue is now outdated. Instead, we now allow extension to the contribute to the |
Problem
Custom editors support untitled resources. However it is currently not easy to open these untitled resources with our existing APIs because the untitled resources need to have a specific file extension. Here's what I have to do today:
This code works but is complex and fragile. For example, it breaks if a file called
newFile.csratch
already exists in the workspaceProposal
In the version of
openTextDocument
that support untitled files, add a new optional parameter for the file extension:This would be used when creating the new file name so that custom editors can correctly enable themselves for it
The text was updated successfully, but these errors were encountered: