From a938f5a87a2b67dd8667337cd569cc6627d0f666 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Sat, 21 Aug 2021 17:21:35 +0300 Subject: refactor: handle DAP events in editor main loop --- helix-term/src/application.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'helix-term/src/application.rs') diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 011dafee..dad6df2b 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -1,4 +1,5 @@ use helix_core::syntax; +use helix_dap::Payload; use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap}; use helix_view::{theme, Editor}; @@ -184,6 +185,29 @@ impl Application { last_render = Instant::now(); } } + Some(payload) = self.editor.debugger_events.next() => { + let mut debugger = self.editor.debugger.as_mut().unwrap(); + match payload { + Payload::Event(ev) => { + match &ev.event[..] { + "stopped" => { + let main = debugger + .threads() + .await + .ok() + .and_then(|threads| threads.get(0).cloned()); + if let Some(main) = main { + let (bt, _) = debugger.stack_trace(main.id).await.unwrap(); + debugger.stack_pointer = bt.get(0).cloned(); + } + } + _ => {} + } + }, + Payload::Response(_) => unreachable!(), + Payload::Request(_) => todo!(), + } + } Some(callback) = self.jobs.futures.next() => { self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback); self.render(); -- cgit v1.2.3-70-g09d2