on master help sign in
dap: small TODO
commit289303a30d8518890ae708b7fdd4996830df8642 authorBlaž Hrastnik <blaz@mxxn.io> dateFri 3 Sep 2021, 11:48 (5 years ago) parent42f9718
5 files changed+12−30
helix-dap/src/client.rs−2 helix-term/src/application.rs+7−2 helix-term/src/commands.rs−1 helix-term/src/commands/dap.rs+5−24 helix-term/src/keymap.rs−1
helix-dap/src/client.rs−2
@@ -35,7 +35,6 @@ pub struct Client {
3535 pub thread_id: Option<usize>,
3636 /// Currently active frame for the current thread.
3737 pub active_frame: Option<usize>,
38− pub is_running: bool, // TODO: track is_running per thread
3938}
4039
4140impl Client {
@@ -83,7 +82,6 @@ impl Client {
8382 thread_states: HashMap::new(),
8483 thread_id: None,
8584 active_frame: None,
86− is_running: false,
8785 };
8886
8987 tokio::spawn(Self::recv(server_rx, client_rx));
helix-term/src/application.rs+7−2
@@ -323,8 +323,13 @@ impl Application {
323323 self.editor.set_status(format!("{} {}", prefix, output));
324324 }
325325 Event::Initialized => {
326− self.editor
327− .set_status("Debugged application started".to_owned());
326+ // send existing breakpoints
327+ // TODO: fetch breakpoints (in case we're attaching)
328+
329+ if let Ok(_) = debugger.configuration_done().await {
330+ self.editor
331+ .set_status("Debugged application started".to_owned());
332+ }; // TODO: do we need to handle error?
328333 }
329334 ev => {
330335 log::warn!("Unhandled event {:?}", ev);
helix-term/src/commands.rs−1
@@ -310,7 +310,6 @@ impl Command {
310310 select_textobject_inner, "Select inside object",
311311 dap_launch, "Launch debug target",
312312 dap_toggle_breakpoint, "Toggle breakpoint",
313− dap_run, "Begin program execution",
314313 dap_continue, "Continue program execution",
315314 dap_pause, "Pause program execution",
316315 dap_step_in, "Step in",
helix-term/src/commands/dap.rs+5−24
@@ -100,7 +100,7 @@ fn thread_picker(cx: &mut Context, callback_fn: impl Fn(&mut Editor, &dap::Threa
100100 let picker = Picker::new(
101101 true,
102102 threads,
103− |thread| thread.name.clone().into(),
103+ |thread| thread.name.clone().into(), // TODO: include thread_states in the label
104104 move |editor, thread, _action| callback_fn(editor, thread),
105105 );
106106 cx.push_layer(Box::new(picker))
@@ -300,25 +300,6 @@ pub fn dap_toggle_breakpoint(cx: &mut Context) {
300300 }
301301}
302302
303−pub fn dap_run(cx: &mut Context) {
304− let debugger = match &mut cx.editor.debugger {
305− Some(debugger) => debugger,
306− None => return,
307− };
308−
309− if debugger.is_running {
310− cx.editor
311− .set_status("Debuggee is already running".to_owned());
312− return;
313− }
314− let request = debugger.configuration_done();
315− if let Err(e) = block_on(request) {
316− cx.editor.set_error(format!("Failed to run: {:?}", e));
317− return;
318− }
319− debugger.is_running = true;
320−}
321−
322303pub fn dap_continue(cx: &mut Context) {
323304 let debugger = match &mut cx.editor.debugger {
324305 Some(debugger) => debugger,
@@ -340,10 +321,10 @@ pub fn dap_continue(cx: &mut Context) {
340321
341322pub fn dap_pause(cx: &mut Context) {
342323 thread_picker(cx, |editor, thread| {
343− let debugger = match &mut editor.debugger {
344− Some(debugger) => debugger,
345− None => return,
346− };
324+ let debugger = match &mut editor.debugger {
325+ Some(debugger) => debugger,
326+ None => return,
327+ };
347328 let request = debugger.pause(thread.id);
348329 // NOTE: we don't need to set active thread id here because DAP will emit a "stopped" event
349330 if let Err(e) = block_on(request) {
helix-term/src/keymap.rs−1
@@ -490,7 +490,6 @@ impl Default for Keymaps {
490490 "d" => { "Debug"
491491 "l" => dap_launch,
492492 "b" => dap_toggle_breakpoint,
493− "r" => dap_run,
494493 "c" => dap_continue,
495494 "h" => dap_pause,
496495 "i" => dap_step_in,