-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
launch-config should allow me reference any command #12735
Comments
I agree that this step of defining @weinand let us know what you think. I might be missing something here |
@isidorn yes, making commands directly available as variables makes sense and we should support this (and we should continue to support the 'variables' contribution). What I don't like is the resulting syntax. If the command ID follows the common practice to use '.' as separators then using the 'command.' prefix makes things a bit unwieldy: "program": "${command.extension.node-debug.pickProcess}" For this the 'variables' contribution helped because it allowed to introduce a short (but scoped) alias: "program": "${command.pickProcess}" TL;DR: The reasoning behind the intermediate 'variables' contribution point was twofold:
Today the first reason is no longer valid: since dynamic variables use the |
Related question: is it currently supported to use the command variable syntax in the 'args' or 'env' parameters of a launch configuration (at the top-level, not in the configurationAttributes)? I tried it yesterday and it didn't seem to work, the debug adapter got the argument but it was the command syntax string and not the resolved value. This would be a huge benefit in my case as the alternative is to write a bunch of extra code in my TypeScript-based debug adapter bridge just to read the request that contains the properties defined in my launch config (since the command syntax seems to work there). |
That's great news. Here's what I've done so you can verify whether I've made a mistake somewhere or if it's a bug: Registering and using the command variable in
Registering the command:
And here's what I see in the
|
Also, I never see my command get invoked when I start my debugger. I've got a breakpoint set in my extension code where I register the command and it never gets hit. Strangely, I don't see the command get invoked even when I use it in a configuration attribute:
|
@daviwil are you expecting variable substitution to take place in the package.json? That won't work. You can use variables in the |
@daviwil and make sure that the extension gets activated when the command is executed, so add all commands to the "activationEvents": [
"onCommand:extension.pickNodeProcess",
"onCommand:extension.node-debug.provideInitialConfigurations"
], |
@daviwil and make sure that all those package.json contributions are only registered if you run your extension. Just editing package.json and then running the debug adapter isn't enough. You'll have to run (or better debug) the extension and from the new VS Code window you can start the launch config. |
I'm expecting the variable substitution to happen for my debug adapter's My extension is already activated at this point (but I am aware that I'll need the activation event in case the user somehow starts the debugger if it's not activated yet). |
Yep, I am debugging my extension using a new instance of VS Code with |
Variable substitution only takes place for all attribute values of a selected launch configuration when a new debug session is started. I don't understand what you mean by "doesn't happen outside of the configurationAttributes section" since variable substitution does not even take place "inside" the configurationAttributes section. Substitution occurs when the launch config is started. |
Yes, I intend for this substitution to occur when the launch config starts, I'm not concerned with launch config creation time because I need the debug adapter's arguments to be populated using a command at the moment when the debugger gets launched. Maybe it would help to say step-by-step what I expect to happen:
I apologize for the lack of clarity in my questions, thanks a lot for helping me with this! |
No variable substitution occurs in your step 3 because "the adapter's command line arguments" are not part of a launch config (and variable substitution only occurs for launch configs). In your initial question I assumed that you were referring to the 'args' or 'env' parameters of a launch configuration (which are passed to the 'launch' request of the debug adapter). But actually you were asking about 'args' passed to the debug adapter itself (and 'env' is not even supported here). We do not support variable substitution for arguments that are passed to the debug adapter (and we probably never will). But we are considering to open up the whole process of launching a debug adapter by moving it to the extension (optionally). With this you could write extension code that launches the debug adapter and can pass whatever arguments it needs. |
Thanks for the clarification! I would love it if you allowed extension code to launch the debug adapter process, that would enable a few things I've been hoping to accomplish. For now I'll just find another way to do what I need to do. |
This is now supported, created microsoft/vscode-docs#689 to update the docs |
I've created #16064 with a proposal for better command variable syntax. |
@weinand I'm writing a extension to provide debug configurations. as mentioned at docs my question is how to link a command to had try the command is not trigger. |
@weinand any suggest? |
I wanna write an extension that is a set of commands for asking for user input, like input text, make selection etc. Then I want to use commands from that extension in our launch.config - my ultimate goal is support
mocha -g "test name"
from within VS Code.I have modified our launch.json so
and an extension that contributes a
inputs.text
command and that activates on that commandThis doesn't work and it requires me to also define a debugger which I believe is unnecessary complicated.
The text was updated successfully, but these errors were encountered: