on master help sign in
Check capabilities for breakpoint config
fdad7d6Dmitry Sharshakov
helix-dap/src/client.rs+4−6
@@ -26,7 +26,7 @@ pub struct Client {
26 _process: Option<Child>,
26 _process: Option<Child>,
27 server_tx: UnboundedSender<Request>,
27 server_tx: UnboundedSender<Request>,
28 request_counter: AtomicU64,
28 request_counter: AtomicU64,
29− capabilities: Option<DebuggerCapabilities>,
29+ pub caps: Option<DebuggerCapabilities>,
30 //
30 //
31 pub breakpoints: HashMap<PathBuf, Vec<SourceBreakpoint>>,
31 pub breakpoints: HashMap<PathBuf, Vec<SourceBreakpoint>>,
32 // TODO: multiple threads support
32 // TODO: multiple threads support
@@ -77,7 +77,7 @@ impl Client {
77 _process: process,
77 _process: process,
78 server_tx,
78 server_tx,
79 request_counter: AtomicU64::new(0),
79 request_counter: AtomicU64::new(0),
80− capabilities: None,
80+ caps: None,
81 //
81 //
82 breakpoints: HashMap::new(),
82 breakpoints: HashMap::new(),
83 stack_pointer: None,
83 stack_pointer: None,
@@ -225,9 +225,7 @@ impl Client {
225 }
225 }
226
226
227 pub fn capabilities(&self) -> &DebuggerCapabilities {
227 pub fn capabilities(&self) -> &DebuggerCapabilities {
228− self.capabilities
229− .as_ref()
230− .expect("debugger not yet initialized!")
228+ self.caps.as_ref().expect("debugger not yet initialized!")
231 }
229 }
232
230
233 pub async fn initialize(&mut self, adapter_id: String) -> Result<()> {
231 pub async fn initialize(&mut self, adapter_id: String) -> Result<()> {
@@ -248,7 +246,7 @@ impl Client {
248 };
246 };
249
247
250 let response = self.request::<requests::Initialize>(args).await?;
248 let response = self.request::<requests::Initialize>(args).await?;
251− self.capabilities = Some(response);
249+ self.caps = Some(response);
252
250
253 Ok(())
251 Ok(())
254 }
252 }
helix-term/src/commands.rs+28
@@ -1949,6 +1949,34 @@ mod cmd {
1949 }
1949 }
1950 };
1950 };
1951 if let Some(debugger) = &mut cx.editor.debugger {
1951 if let Some(debugger) = &mut cx.editor.debugger {
1952+ if breakpoint.condition.is_some()
1953+ && !debugger
1954+ .caps
1955+ .clone()
1956+ .unwrap()
1957+ .supports_conditional_breakpoints
1958+ .unwrap_or_default()
1959+ {
1960+ cx.editor.set_error(
1961+ "Can't edit breakpoint: debugger does not support conditional breakpoints"
1962+ .to_string(),
1963+ );
1964+ return;
1965+ }
1966+ if breakpoint.log_message.is_some()
1967+ && !debugger
1968+ .caps
1969+ .clone()
1970+ .unwrap()
1971+ .supports_log_points
1972+ .unwrap_or_default()
1973+ {
1974+ cx.editor.set_error(
1975+ "Can't edit breakpoint: debugger does not support logpoints".to_string(),
1976+ );
1977+ return;
1978+ }
1979+
1952 let breakpoints = debugger.breakpoints.entry(path.clone()).or_default();
1980 let breakpoints = debugger.breakpoints.entry(path.clone()).or_default();
1953 if let Some(pos) = breakpoints.iter().position(|b| b.line == breakpoint.line) {
1981 if let Some(pos) = breakpoints.iter().position(|b| b.line == breakpoint.line) {
1954 breakpoints.remove(pos);
1982 breakpoints.remove(pos);