@@ -40,17 +40,6 @@ pub fn dap_pos_to_pos(doc: &helix_core::Rope, line: usize, column: usize) -> Opt
4040 Some(pos)
4141}
4242
43−pub fn resume_application(debugger: &mut Client) {
44− if let Some(thread_id) = debugger.thread_id {
45− debugger
46− .thread_states
47− .insert(thread_id, "running".to_string());
48− debugger.stack_frames.remove(&thread_id);
49− }
50− debugger.active_frame = None;
51− debugger.thread_id = None;
52−}
53−
5443pub async fn select_thread_id(editor: &mut Editor, thread_id: ThreadId, force: bool) {
5544 let debugger = debugger!(editor);
5645
@@ -518,11 +507,14 @@ pub fn dap_continue(cx: &mut Context) {
518507
519508 if let Some(thread_id) = debugger.thread_id {
520509 let request = debugger.continue_thread(thread_id);
521− if let Err(e) = block_on(request) {
522− cx.editor.set_error(format!("Failed to continue: {}", e));
523− return;
524− }
525− resume_application(debugger);
510+
511+ dap_callback(
512+ cx.jobs,
513+ request,
514+ |editor, _compositor, _response: dap::requests::ContinueResponse| {
515+ debugger!(editor).resume_application();
516+ },
517+ );
526518 } else {
527519 cx.editor
528520 .set_error("Currently active thread is not stopped. Switch the thread.".into());
@@ -545,11 +537,10 @@ pub fn dap_step_in(cx: &mut Context) {
545537
546538 if let Some(thread_id) = debugger.thread_id {
547539 let request = debugger.step_in(thread_id);
548− if let Err(e) = block_on(request) {
549− cx.editor.set_error(format!("Failed to continue: {}", e));
550− return;
551− }
552− resume_application(debugger);
540+
541+ dap_callback(cx.jobs, request, |editor, _compositor, _response: ()| {
542+ debugger!(editor).resume_application();
543+ });
553544 } else {
554545 cx.editor
555546 .set_error("Currently active thread is not stopped. Switch the thread.".into());
@@ -561,11 +552,9 @@ pub fn dap_step_out(cx: &mut Context) {
561552
562553 if let Some(thread_id) = debugger.thread_id {
563554 let request = debugger.step_out(thread_id);
564− if let Err(e) = block_on(request) {
565− cx.editor.set_error(format!("Failed to continue: {}", e));
566− return;
567− }
568− resume_application(debugger);
555+ dap_callback(cx.jobs, request, |editor, _compositor, _response: ()| {
556+ debugger!(editor).resume_application();
557+ });
569558 } else {
570559 cx.editor
571560 .set_error("Currently active thread is not stopped. Switch the thread.".into());
@@ -577,11 +566,9 @@ pub fn dap_next(cx: &mut Context) {
577566
578567 if let Some(thread_id) = debugger.thread_id {
579568 let request = debugger.next(thread_id);
580− if let Err(e) = block_on(request) {
581− cx.editor.set_error(format!("Failed to continue: {}", e));
582− return;
583− }
584− resume_application(debugger);
569+ dap_callback(cx.jobs, request, |editor, _compositor, _response: ()| {
570+ debugger!(editor).resume_application();
571+ });
585572 } else {
586573 cx.editor
587574 .set_error("Currently active thread is not stopped. Switch the thread.".into());
@@ -658,11 +645,10 @@ pub fn dap_terminate(cx: &mut Context) {
658645 let debugger = debugger!(cx.editor);
659646
660647 let request = debugger.disconnect();
661− if let Err(e) = block_on(request) {
662− cx.editor.set_error(format!("Failed to disconnect: {}", e));
663− return;
664− }
665− cx.editor.debugger = None;
648+ dap_callback(cx.jobs, request, |editor, _compositor, _response: ()| {
649+ // editor.set_error(format!("Failed to disconnect: {}", e));
650+ editor.debugger = None;
651+ });
666652}
667653
668654pub fn dap_enable_exceptions(cx: &mut Context) {
@@ -673,19 +659,29 @@ pub fn dap_enable_exceptions(cx: &mut Context) {
673659 None => return,
674660 };
675661
676− if let Err(e) = block_on(debugger.set_exception_breakpoints(filters)) {
677− cx.editor
678− .set_error(format!("Failed to set up exception breakpoints: {}", e));
679− }
662+ let request = debugger.set_exception_breakpoints(filters);
663+
664+ dap_callback(
665+ cx.jobs,
666+ request,
667+ |_editor, _compositor, _response: dap::requests::SetExceptionBreakpointsResponse| {
668+ // editor.set_error(format!("Failed to set up exception breakpoints: {}", e));
669+ },
670+ )
680671}
681672
682673pub fn dap_disable_exceptions(cx: &mut Context) {
683674 let debugger = debugger!(cx.editor);
684675
685− if let Err(e) = block_on(debugger.set_exception_breakpoints(Vec::new())) {
686− cx.editor
687− .set_error(format!("Failed to set up exception breakpoints: {}", e));
688− }
676+ let request = debugger.set_exception_breakpoints(Vec::new());
677+
678+ dap_callback(
679+ cx.jobs,
680+ request,
681+ |_editor, _compositor, _response: dap::requests::SetExceptionBreakpointsResponse| {
682+ // editor.set_error(format!("Failed to set up exception breakpoints: {}", e));
683+ },
684+ )
689685}
690686
691687// TODO: both edit condition and edit log need to be stable: we might get new breakpoints from the debugger which can change offsets