-
Notifications
You must be signed in to change notification settings - Fork 30.2k
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
Provide a command to create a new untitled file with a specific language set #152920
Comments
Can you not use this API? vscode/src/vscode-dts/vscode.d.ts Line 12290 in 96ca512
|
Extension takes some while to activate, so any commands we register ourselves using the API aren't available at startup. |
I am a bit confused, how can there be a python specific welcome command without the python extension? |
I think such a change would be relatively easy, similar to the view type argument: vscode/src/vs/workbench/contrib/files/browser/fileCommands.ts Lines 620 to 656 in 96ca512
I think this can come in as a PR, if it turns out to be working. |
Opening python specific getting started doesn't require a command, it uses |
That's great. Just to doublecheck, is it possible to call |
You mean define a keybinding for said command with arguments or how/where are the arguments defined? Technically you don't "call" a command from package.json, you can only reference them |
I believe kartik is referring to a command link in the statically defined walkthroughs within the package.json |
Yes
Right, can I reference such a command with arguments in walkthroughs within
where |
Yes, for example GitLens does this: [GitLens: Welcome (Quick Setup)](command:gitlens.showWelcomePage?%22quick-setup%22)
No, vscode/src/vs/workbench/contrib/files/browser/fileCommands.ts Lines 625 to 644 in c12c8c1
You can activate your extension when the command is invoked. GitLens also does this:
|
Gotcha, thanks. I assume it's URI encoded.
That is what this feature request is for :)
We don't have our own specific open walkthrough command, so our walkthrough is opened before commands finish registering, i.e our command may not be registered by the time |
Open for a contribution after validation it works from welcome 👍 |
@karrtikr Just fyi that the "format" of such arguments is the following: JSON.stringify the arguments, then encodeURIComponent the result, and use that as URI query. |
VSCode provides
workbench.action.files.newUntitledFile
using which we can create a new untitled file, which then instructs to set a particular language:We're working on our walkthrough in Python extension which directly offers to create a new python file, it would be great if the command supports an argument which accepts the language to create the file for.
cc/ @lramos15
Unfortunately we cannot use VSCode APIs to accomplish this as extension is not guaranteed to be activated when the walkthrough is opened, so the command isn't available when the button is clicked, see:
The text was updated successfully, but these errors were encountered: