on master help sign in
Check capabilities for breakpoint config
commitfdad7d67aa158c963a4b5397e9d7de960706cd2a authorDmitry Sharshakov <d3dx12.xx@gmail.com> dateTue 24 Aug 2021, 10:48 (5 years ago) parentc4085b4
2 files changed+32−6
helix-dap/src/client.rs+4−6 helix-term/src/commands.rs+28
helix-dap/src/client.rs+4−6
@@ -26,7 +26,7 @@ pub struct Client {
2626 _process: Option<Child>,
2727 server_tx: UnboundedSender<Request>,
2828 request_counter: AtomicU64,
29− capabilities: Option<DebuggerCapabilities>,
29+ pub caps: Option<DebuggerCapabilities>,
3030 //
3131 pub breakpoints: HashMap<PathBuf, Vec<SourceBreakpoint>>,
3232 // TODO: multiple threads support
@@ -77,7 +77,7 @@ impl Client {
7777 _process: process,
7878 server_tx,
7979 request_counter: AtomicU64::new(0),
80− capabilities: None,
80+ caps: None,
8181 //
8282 breakpoints: HashMap::new(),
8383 stack_pointer: None,
@@ -225,9 +225,7 @@ impl Client {
225225 }
226226
227227 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!")
231229 }
232230
233231 pub async fn initialize(&mut self, adapter_id: String) -> Result<()> {
@@ -248,7 +246,7 @@ impl Client {
248246 };
249247
250248 let response = self.request::<requests::Initialize>(args).await?;
251− self.capabilities = Some(response);
249+ self.caps = Some(response);
252250
253251 Ok(())
254252 }
helix-term/src/commands.rs+28
@@ -1949,6 +1949,34 @@ mod cmd {
19491949 }
19501950 };
19511951 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+
19521980 let breakpoints = debugger.breakpoints.entry(path.clone()).or_default();
19531981 if let Some(pos) = breakpoints.iter().position(|b| b.line == breakpoint.line) {
19541982 breakpoints.remove(pos);