From 5a06263b787710d15278a3caa9fef0f302442b61 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Sat, 21 Aug 2021 20:08:37 +0300 Subject: [PATCH] report status when target started or stopped --- helix-term/src/application.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 0e988a1a7..2e7d16db6 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -2,6 +2,7 @@ use helix_dap::Payload; use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap}; use helix_view::{theme, Editor}; +use serde_json::from_value; use crate::{args::Args, compositor::Compositor, config::Config, job::Jobs, ui}; @@ -200,6 +201,29 @@ pub async fn event_loop(&mut self) { let (bt, _) = debugger.stack_trace(main.id).await.unwrap(); debugger.stack_pointer = bt.get(0).cloned(); } + + let body: helix_dap::events::Stopped = from_value(ev.body.expect("`stopped` event must have a body")).unwrap(); + let scope = match body.thread_id { + Some(id) => format!("Thread {}", id), + None => "Target".to_owned(), + }; + + let mut status = format!("{} stopped because of {}", scope, body.reason); + if let Some(desc) = body.description { + status.push_str(&format!(" {}", desc)); + } + if let Some(text) = body.text { + status.push_str(&format!(" {}", text)); + } + if body.all_threads_stopped == Some(true) { + status.push_str(" (all threads stopped)"); + } + + self.editor.set_status(status); + self.render(); + } + "initialized" => { + self.editor.set_status("Debugged application started".to_owned()); self.render(); } _ => {}