@@ -187,76 +187,7 @@ impl Application {
189 Some(payload) = self.editor.debugger_events.next() => {
189 Some(payload) = self.editor.debugger_events.next() => {
190− if self.editor.debugger.is_none() {
190+ self.handle_debugger_message(payload).await;
193− let mut debugger = self.editor.debugger.as_mut().unwrap();
195− Payload::Event(ev) => {
196− match &ev.event[..] {
198− debugger.is_running = false;
203− .and_then(|threads| threads.get(0).cloned());
204− if let Some(main) = main {
205− let (bt, _) = debugger.stack_trace(main.id).await.unwrap();
206− debugger.stack_pointer = bt.get(0).cloned();
209− let body: helix_dap::events::Stopped = from_value(ev.body.expect("`stopped` event must have a body")).unwrap();
210− let scope = match body.thread_id {
211− Some(id) => format!("Thread {}", id),
212− None => "Target".to_owned(),
215− let mut status = format!("{} stopped because of {}", scope, body.reason);
216− if let Some(desc) = body.description {
217− status.push_str(&format!(" {}", desc));
219− if let Some(text) = body.text {
220− status.push_str(&format!(" {}", text));
222− if body.all_threads_stopped == Some(true) {
223− status.push_str(" (all threads stopped)");
226− if let Some(helix_dap::StackFrame {
227− source: Some(helix_dap::Source {
232− }) = &debugger.stack_pointer {
233− let path = src.clone().into();
234− self.editor.open(path, helix_view::editor::Action::Replace).unwrap();
236− self.editor.set_status(status);
240− let body: helix_dap::events::Output = from_value(ev.body.expect("`output` event must have a body")).unwrap();
242− let prefix = match body.category {
243− Some(category) => format!("Debug ({}):", category),
244− None => "Debug:".to_owned(),
247− self.editor.set_status(format!("{} {}", prefix, body.output));
251− self.editor.set_status("Debugged application started".to_owned());
257− Payload::Response(_) => unreachable!(),
258− Payload::Request(_) => todo!(),
261 Some(callback) = self.jobs.futures.next() => {
192 Some(callback) = self.jobs.futures.next() => {
262 self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
193 self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
@@ -319,7 +250,83 @@ impl Application {
322− pub async fn handle_debugger_message(&mut self, _call: ()) {
253+ pub async fn handle_debugger_message(&mut self, payload: helix_dap::Payload) {
254+ let mut debugger = match self.editor.debugger.as_mut() {
255+ Some(debugger) => debugger,
260+ Payload::Event(ev) => match &ev.event[..] {
262+ debugger.is_running = false;
267+ .and_then(|threads| threads.get(0).cloned());
268+ if let Some(main) = main {
269+ let (bt, _) = debugger.stack_trace(main.id).await.unwrap();
270+ debugger.stack_pointer = bt.get(0).cloned();
273+ let body: helix_dap::events::Stopped =
274+ from_value(ev.body.expect("`stopped` event must have a body")).unwrap();
275+ let scope = match body.thread_id {
276+ Some(id) => format!("Thread {}", id),
277+ None => "Target".to_owned(),
280+ let mut status = format!("{} stopped because of {}", scope, body.reason);
281+ if let Some(desc) = body.description {
282+ status.push_str(&format!(" {}", desc));
284+ if let Some(text) = body.text {
285+ status.push_str(&format!(" {}", text));
287+ if body.all_threads_stopped == Some(true) {
288+ status.push_str(" (all threads stopped)");
291+ if let Some(helix_dap::StackFrame {
293+ Some(helix_dap::Source {
297+ }) = &debugger.stack_pointer
299+ let path = src.clone().into();
301+ .open(path, helix_view::editor::Action::Replace)
304+ self.editor.set_status(status);
308+ let body: helix_dap::events::Output =
309+ from_value(ev.body.expect("`output` event must have a body")).unwrap();
311+ let prefix = match body.category {
312+ Some(category) => format!("Debug ({}):", category),
313+ None => "Debug:".to_owned(),
317+ .set_status(format!("{} {}", prefix, body.output));
322+ .set_status("Debugged application started".to_owned());
327+ Payload::Response(_) => unreachable!(),
328+ Payload::Request(_) => todo!(),