on master help sign in
dap: small TODO
289303aBlaž Hrastnik
helix-dap/src/client.rs−2
@@ -35,7 +35,6 @@ pub struct Client {
35 pub thread_id: Option<usize>,
35 pub thread_id: Option<usize>,
36 /// Currently active frame for the current thread.
36 /// Currently active frame for the current thread.
37 pub active_frame: Option<usize>,
37 pub active_frame: Option<usize>,
38− pub is_running: bool, // TODO: track is_running per thread
39}
38}
40
39
41impl Client {
40impl Client {
@@ -83,7 +82,6 @@ impl Client {
83 thread_states: HashMap::new(),
82 thread_states: HashMap::new(),
84 thread_id: None,
83 thread_id: None,
85 active_frame: None,
84 active_frame: None,
86− is_running: false,
87 };
85 };
88
86
89 tokio::spawn(Self::recv(server_rx, client_rx));
87 tokio::spawn(Self::recv(server_rx, client_rx));
helix-term/src/application.rs+7−2
@@ -323,8 +323,13 @@ impl Application {
323 self.editor.set_status(format!("{} {}", prefix, output));
323 self.editor.set_status(format!("{} {}", prefix, output));
324 }
324 }
325 Event::Initialized => {
325 Event::Initialized => {
326+ // send existing breakpoints
327+ // TODO: fetch breakpoints (in case we're attaching)
328+
329+ if let Ok(_) = debugger.configuration_done().await {
326− self.editor
330+ self.editor
327− .set_status("Debugged application started".to_owned());
331+ .set_status("Debugged application started".to_owned());
332+ }; // TODO: do we need to handle error?
328 }
333 }
329 ev => {
334 ev => {
330 log::warn!("Unhandled event {:?}", ev);
335 log::warn!("Unhandled event {:?}", ev);
helix-term/src/commands.rs−1
@@ -310,7 +310,6 @@ impl Command {
310 select_textobject_inner, "Select inside object",
310 select_textobject_inner, "Select inside object",
311 dap_launch, "Launch debug target",
311 dap_launch, "Launch debug target",
312 dap_toggle_breakpoint, "Toggle breakpoint",
312 dap_toggle_breakpoint, "Toggle breakpoint",
313− dap_run, "Begin program execution",
314 dap_continue, "Continue program execution",
313 dap_continue, "Continue program execution",
315 dap_pause, "Pause program execution",
314 dap_pause, "Pause program execution",
316 dap_step_in, "Step in",
315 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
100 let picker = Picker::new(
100 let picker = Picker::new(
101 true,
101 true,
102 threads,
102 threads,
103− |thread| thread.name.clone().into(),
103+ |thread| thread.name.clone().into(), // TODO: include thread_states in the label
104 move |editor, thread, _action| callback_fn(editor, thread),
104 move |editor, thread, _action| callback_fn(editor, thread),
105 );
105 );
106 cx.push_layer(Box::new(picker))
106 cx.push_layer(Box::new(picker))
@@ -300,25 +300,6 @@ pub fn dap_toggle_breakpoint(cx: &mut Context) {
300 }
300 }
301}
301}
302
302
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−
322pub fn dap_continue(cx: &mut Context) {
303pub fn dap_continue(cx: &mut Context) {
323 let debugger = match &mut cx.editor.debugger {
304 let debugger = match &mut cx.editor.debugger {
324 Some(debugger) => debugger,
305 Some(debugger) => debugger,
@@ -340,10 +321,10 @@ pub fn dap_continue(cx: &mut Context) {
340
321
341pub fn dap_pause(cx: &mut Context) {
322pub fn dap_pause(cx: &mut Context) {
342 thread_picker(cx, |editor, thread| {
323 thread_picker(cx, |editor, thread| {
343− let debugger = match &mut editor.debugger {
324+ let debugger = match &mut editor.debugger {
344− Some(debugger) => debugger,
325+ Some(debugger) => debugger,
345− None => return,
326+ None => return,
346− };
327+ };
347 let request = debugger.pause(thread.id);
328 let request = debugger.pause(thread.id);
348 // NOTE: we don't need to set active thread id here because DAP will emit a "stopped" event
329 // NOTE: we don't need to set active thread id here because DAP will emit a "stopped" event
349 if let Err(e) = block_on(request) {
330 if let Err(e) = block_on(request) {
helix-term/src/keymap.rs−1
@@ -490,7 +490,6 @@ impl Default for Keymaps {
490 "d" => { "Debug"
490 "d" => { "Debug"
491 "l" => dap_launch,
491 "l" => dap_launch,
492 "b" => dap_toggle_breakpoint,
492 "b" => dap_toggle_breakpoint,
493− "r" => dap_run,
494 "c" => dap_continue,
493 "c" => dap_continue,
495 "h" => dap_pause,
494 "h" => dap_pause,
496 "i" => dap_step_in,
495 "i" => dap_step_in,