1

I was able to generate a launch.json file with the VSCode Rust debugger; The tool is smart enough to create a configuration array with multiple configurations, one for each package in my project; so far so good. Except that a Start Debugging always choose the first configuration in the list.

Do I need to place the configuration I want to launch at the beginning of the array, or is there a way to specify a specific name in the list?

1 Answer 1

2

Open the Run and Debug sidebar (Debug sidebar icon, Ctrl/Cmd+Shift+D), and in the list choose the configuration to launch.

Choose a debug configuration

For one time, you can open the Command Palette (Ctrl/Cmd+Shift+P), and choose "Debug: Select and Start Debugging". Then choose the desired configuration.

If you want to bind it to a shortcut, edit your keybindings.json and add:

{
    "key": /* shortcut, e.g. */ "ctrl+alt+k ctrl+alt+k",
    "command": "debug.startFromConfig",
    "args": /* full launch configuration. you cannot rely on configurations specified in launch.json, unfortunately */ {}
}

Unfortunately, there's no way to apply keybindings per-workspace. See A keybindings.json per workspace in Visual Studio Code.

See Allow key binding for individual launch configurations for more.

Sign up to request clarification or add additional context in comments.

5 Comments

This. And as far as I know, there's no command to Run ...<ask me>. F5 (default key?) will launch the selected one but you have to make your way there to select it. I never looked into ways to set a keyboard shortcut to launch different ones, perhaps that's possible.
@MartinMarconcini There is the command "Select and Start Debugging" and you can bind it to a keybinding, but I don't know a way to associate a keybdinding with a specific launch configuration, unfortunately.
Ahh good point. I'm not too familiar with vscode so I don't know either. I run VSCodium instead and it (naturally) is the same.
From the github link: "Just in case, in a few simple steps you can get started writing your own extension". Have they ever heard of NIH and DRY? Sure,, I can rewrite vscode to support configuration launch too!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.