@@ -40,17 +40,6 @@ pub fn dap_pos_to_pos(doc: &helix_core::Rope, line: usize, column: usize) -> Opt
43−pub fn resume_application(debugger: &mut Client) {
44− if let Some(thread_id) = debugger.thread_id {
47− .insert(thread_id, "running".to_string());
48− debugger.stack_frames.remove(&thread_id);
50− debugger.active_frame = None;
51− debugger.thread_id = None;
54pub async fn select_thread_id(editor: &mut Editor, thread_id: ThreadId, force: bool) {
43pub async fn select_thread_id(editor: &mut Editor, thread_id: ThreadId, force: bool) {
55 let debugger = debugger!(editor);
44 let debugger = debugger!(editor);
@@ -518,11 +507,14 @@ pub fn dap_continue(cx: &mut Context) {
519 if let Some(thread_id) = debugger.thread_id {
508 if let Some(thread_id) = debugger.thread_id {
520 let request = debugger.continue_thread(thread_id);
509 let request = debugger.continue_thread(thread_id);
521− if let Err(e) = block_on(request) {
510+
522− cx.editor.set_error(format!("Failed to continue: {}", e));
511+ dap_callback(
523− return;
512+ cx.jobs,
525− resume_application(debugger);
514+ |editor, _compositor, _response: dap::requests::ContinueResponse| {
515+ debugger!(editor).resume_application();
527 cx.editor
519 cx.editor
528 .set_error("Currently active thread is not stopped. Switch the thread.".into());
520 .set_error("Currently active thread is not stopped. Switch the thread.".into());
@@ -545,11 +537,10 @@ pub fn dap_step_in(cx: &mut Context) {
546 if let Some(thread_id) = debugger.thread_id {
538 if let Some(thread_id) = debugger.thread_id {
547 let request = debugger.step_in(thread_id);
539 let request = debugger.step_in(thread_id);
548− if let Err(e) = block_on(request) {
540+
549− cx.editor.set_error(format!("Failed to continue: {}", e));
541+ dap_callback(cx.jobs, request, |editor, _compositor, _response: ()| {
552− resume_application(debugger);
542+ debugger!(editor).resume_application();
554 cx.editor
545 cx.editor
555 .set_error("Currently active thread is not stopped. Switch the thread.".into());
546 .set_error("Currently active thread is not stopped. Switch the thread.".into());
@@ -561,11 +552,9 @@ pub fn dap_step_out(cx: &mut Context) {
562 if let Some(thread_id) = debugger.thread_id {
553 if let Some(thread_id) = debugger.thread_id {
563 let request = debugger.step_out(thread_id);
554 let request = debugger.step_out(thread_id);
564− if let Err(e) = block_on(request) {
555+ dap_callback(cx.jobs, request, |editor, _compositor, _response: ()| {
565− cx.editor.set_error(format!("Failed to continue: {}", e));
568− resume_application(debugger);
556+ debugger!(editor).resume_application();
570 cx.editor
559 cx.editor
571 .set_error("Currently active thread is not stopped. Switch the thread.".into());
560 .set_error("Currently active thread is not stopped. Switch the thread.".into());
@@ -577,11 +566,9 @@ pub fn dap_next(cx: &mut Context) {
578 if let Some(thread_id) = debugger.thread_id {
567 if let Some(thread_id) = debugger.thread_id {
579 let request = debugger.next(thread_id);
568 let request = debugger.next(thread_id);
580− if let Err(e) = block_on(request) {
569+ dap_callback(cx.jobs, request, |editor, _compositor, _response: ()| {
581− cx.editor.set_error(format!("Failed to continue: {}", e));
584− resume_application(debugger);
570+ debugger!(editor).resume_application();
586 cx.editor
573 cx.editor
587 .set_error("Currently active thread is not stopped. Switch the thread.".into());
574 .set_error("Currently active thread is not stopped. Switch the thread.".into());
@@ -658,11 +645,10 @@ pub fn dap_terminate(cx: &mut Context) {
658 let debugger = debugger!(cx.editor);
645 let debugger = debugger!(cx.editor);
660 let request = debugger.disconnect();
647 let request = debugger.disconnect();
661− if let Err(e) = block_on(request) {
648+ dap_callback(cx.jobs, request, |editor, _compositor, _response: ()| {
662− cx.editor.set_error(format!("Failed to disconnect: {}", e));
649+ // editor.set_error(format!("Failed to disconnect: {}", e));
665− cx.editor.debugger = None;
650+ editor.debugger = None;
668pub fn dap_enable_exceptions(cx: &mut Context) {
654pub fn dap_enable_exceptions(cx: &mut Context) {
@@ -673,19 +659,29 @@ pub fn dap_enable_exceptions(cx: &mut Context) {
673 None => return,
659 None => return,
676− if let Err(e) = block_on(debugger.set_exception_breakpoints(filters)) {
662+ let request = debugger.set_exception_breakpoints(filters);
667+ |_editor, _compositor, _response: dap::requests::SetExceptionBreakpointsResponse| {
678− .set_error(format!("Failed to set up exception breakpoints: {}", e));
668+ // editor.set_error(format!("Failed to set up exception breakpoints: {}", e));
682pub fn dap_disable_exceptions(cx: &mut Context) {
673pub fn dap_disable_exceptions(cx: &mut Context) {
683 let debugger = debugger!(cx.editor);
674 let debugger = debugger!(cx.editor);
685− if let Err(e) = block_on(debugger.set_exception_breakpoints(Vec::new())) {
676+ let request = debugger.set_exception_breakpoints(Vec::new());
681+ |_editor, _compositor, _response: dap::requests::SetExceptionBreakpointsResponse| {
687− .set_error(format!("Failed to set up exception breakpoints: {}", e));
682+ // editor.set_error(format!("Failed to set up exception breakpoints: {}", e));
691// TODO: both edit condition and edit log need to be stable: we might get new breakpoints from the debugger which can change offsets
687// TODO: both edit condition and edit log need to be stable: we might get new breakpoints from the debugger which can change offsets