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?

John Difool
  • 5,572
  • 5
  • 45
  • 80

1 Answers1

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.

Chayim Friedman
  • 47,971
  • 5
  • 48
  • 77
  • This. And as far as I know, there's no command to `Run ...`. 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. – Martin Marconcini Feb 25 '22 at 10:25
  • 2
    @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. – Chayim Friedman Feb 25 '22 at 10:36
  • 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. – Martin Marconcini Feb 25 '22 at 10:38
  • 2
    Found https://github.com/microsoft/vscode/issues/97921. – Chayim Friedman Feb 25 '22 at 10:38
  • 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! – John Difool Feb 26 '22 at 00:10