From fdad7d67aa158c963a4b5397e9d7de960706cd2a Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Tue, 24 Aug 2021 10:48:47 +0300 Subject: Check capabilities for breakpoint config --- helix-dap/src/client.rs | 10 ++++------ helix-term/src/commands.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs index 9a2e3920..94a76a54 100644 --- a/helix-dap/src/client.rs +++ b/helix-dap/src/client.rs @@ -26,7 +26,7 @@ pub struct Client { _process: Option, server_tx: UnboundedSender, request_counter: AtomicU64, - capabilities: Option, + pub caps: Option, // pub breakpoints: HashMap>, // TODO: multiple threads support @@ -77,7 +77,7 @@ impl Client { _process: process, server_tx, request_counter: AtomicU64::new(0), - capabilities: None, + caps: None, // breakpoints: HashMap::new(), stack_pointer: None, @@ -225,9 +225,7 @@ impl Client { } pub fn capabilities(&self) -> &DebuggerCapabilities { - self.capabilities - .as_ref() - .expect("debugger not yet initialized!") + self.caps.as_ref().expect("debugger not yet initialized!") } pub async fn initialize(&mut self, adapter_id: String) -> Result<()> { @@ -248,7 +246,7 @@ impl Client { }; let response = self.request::(args).await?; - self.capabilities = Some(response); + self.caps = Some(response); Ok(()) } diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 42591ac4..74466e7e 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1949,6 +1949,34 @@ mod cmd { } }; if let Some(debugger) = &mut cx.editor.debugger { + if breakpoint.condition.is_some() + && !debugger + .caps + .clone() + .unwrap() + .supports_conditional_breakpoints + .unwrap_or_default() + { + cx.editor.set_error( + "Can't edit breakpoint: debugger does not support conditional breakpoints" + .to_string(), + ); + return; + } + if breakpoint.log_message.is_some() + && !debugger + .caps + .clone() + .unwrap() + .supports_log_points + .unwrap_or_default() + { + cx.editor.set_error( + "Can't edit breakpoint: debugger does not support logpoints".to_string(), + ); + return; + } + let breakpoints = debugger.breakpoints.entry(path.clone()).or_default(); if let Some(pos) = breakpoints.iter().position(|b| b.line == breakpoint.line) { breakpoints.remove(pos); -- cgit v1.2.3-70-g09d2