diff options
author | Filip Dutescu | 2023-03-06 09:19:53 +0000 |
---|---|---|
committer | GitHub | 2023-03-06 09:19:53 +0000 |
commit | 376c19e06bedf54c8a897068f25ff7b9a8e75198 (patch) | |
tree | 8870f38c002969779f73efad7f0f78bc54f0d678 /helix-term/src/commands | |
parent | 39d5fb0e593b0da1bf6e2659c67a7914edcd75a6 (diff) |
feat(dap): implement Restart request (#5651)
Add a restart debug session command, which would issue a
[Restart Request][1], if the debugger supports it and a session is
running. It uses the same arguments and requests used to start the
initial session, when recreating it.
It builds upon #5532, making use of the changes to the termination
workflow of a session.
[1]: https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Restart
Closes: #5594
Signed-off-by: Filip Dutescu <filip.dutescu@gmail.com>
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r-- | helix-term/src/commands/dap.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs index 023ed377..dac1e9d5 100644 --- a/helix-term/src/commands/dap.rs +++ b/helix-term/src/commands/dap.rs @@ -289,6 +289,36 @@ pub fn dap_launch(cx: &mut Context) { )))); } +pub fn dap_restart(cx: &mut Context) { + let debugger = match &cx.editor.debugger { + Some(debugger) => debugger, + None => { + cx.editor.set_error("Debugger is not running"); + return; + } + }; + if !debugger + .capabilities() + .supports_restart_request + .unwrap_or(false) + { + cx.editor + .set_error("Debugger does not support session restarts"); + return; + } + if debugger.starting_request_args().is_none() { + cx.editor + .set_error("No arguments found with which to restart the sessions"); + return; + } + + dap_callback( + cx.jobs, + debugger.restart(), + |editor, _compositor, _resp: ()| editor.set_status("Debugging session restarted"), + ); +} + fn debug_parameter_prompt( completions: Vec<DebugConfigCompletion>, config_name: String, |