-
Notifications
You must be signed in to change notification settings - Fork 28.8k
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
Restart specific debugger using command #114467
Comments
Possibly this extension could help: Launch Debug and assign a keybinding to your renderer debug. |
@DJ4ddi could you give Arturo's extension a try? |
Unfortunately the extension does not solve my issue. I like the approach (defining a command for a specific configuration), but the problem is that it always attempts to start the configuration. In my case, I need it to restart the active one. Attempting to do so using Launch Debug displays the following error: |
Good point, I'll look into stopping the matching debug session first before re-starting the same configuration. It looks doable. |
Cool. Do keep in mind that stopping and starting is not the same as restarting for some debuggers (e.g. Debugger for Chrome, which is used for Electron, reloads the window on restart, but not on re-attach). Edit: Opened and referenced issue on the Launch Configs repository. From looking into this, it does not seem like the VSCode API has access to the information needed to restart a debugging session (as neither the capability nor the restart function are exposed). |
@weinand Looks like implementing this functionality in an extension would require an API to restart a |
Most built-in commands (like "Restart") have an ID ("workbench.action.debug.restart") and can be executed via the |
The command you suggested restarts the currently selected debugging instance, which is not the desired behavior here and the reason why this ticket exists. There is no way to restart a different instance via commands or the API. |
@isidorn any idea how to address this issue? |
@weinand that sounds like a good approach and it might already work looking at the code here @DJ4ddi you should be able to execute the Let me know how it goes. |
Great, that worked (second argument is the correct one). Code sample for my use case: var sessions = [];
function activate() {
vscode.debug.onDidStartDebugSession(session => sessions.push(session.id));
vscode.debug.onDidTerminateDebugSession(session => sessions = sessions.filter(sid => sid !== session.id));
vscode.commands.registerCommand("workbench.action.debug.restartLatest",
() => vscode.commands.executeCommand("workbench.action.debug.restart", "", { sessionId: sessions[sessions.length - 1] });
} @ArturoDent this might interest you as well. |
Hi there.
A bit of background for the setup: I'm working with an Electron application, which requires two different debugging configurations - one for the main process, one for the renderer. I set up my
launch.json
so that the chrome attach automatically runs when the node launch is done starting (the same could also be achieved through a compound configuration).But this setup has a major inconvenience: Whenever a task, extension or the user runs the "Debug: Restart" command, it restarts the configuration that is currently selected in the debugging widget (the one with the pause, continue and step buttons) or the "Debug Console" tab. By default, that's the main process launcher. Unfortunately, in 99% of cases the intended behavior is to restart the renderer, not the launcher, which means that the wrong debugger is restarted if the user doesn't pay attention to the currently selected one.
What I want to do is to configure a preferred debugger that will be restarted when the
workbench.action.debug.restart
command is invoked.${command:<command>}
syntax).I am, of course, open for alternative solutions.
The text was updated successfully, but these errors were encountered: