mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-09-19 03:57:09 +03:00
Check capabilities for breakpoint config
This commit is contained in:
parent
c4085b4e88
commit
fdad7d67aa
@ -26,7 +26,7 @@ pub struct Client {
|
||||
_process: Option<Child>,
|
||||
server_tx: UnboundedSender<Request>,
|
||||
request_counter: AtomicU64,
|
||||
capabilities: Option<DebuggerCapabilities>,
|
||||
pub caps: Option<DebuggerCapabilities>,
|
||||
//
|
||||
pub breakpoints: HashMap<PathBuf, Vec<SourceBreakpoint>>,
|
||||
// TODO: multiple threads support
|
||||
@ -77,7 +77,7 @@ pub fn streams(
|
||||
_process: process,
|
||||
server_tx,
|
||||
request_counter: AtomicU64::new(0),
|
||||
capabilities: None,
|
||||
caps: None,
|
||||
//
|
||||
breakpoints: HashMap::new(),
|
||||
stack_pointer: None,
|
||||
@ -225,9 +225,7 @@ async fn request<R: crate::types::Request>(
|
||||
}
|
||||
|
||||
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 @@ pub async fn initialize(&mut self, adapter_id: String) -> Result<()> {
|
||||
};
|
||||
|
||||
let response = self.request::<requests::Initialize>(args).await?;
|
||||
self.capabilities = Some(response);
|
||||
self.caps = Some(response);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1949,6 +1949,34 @@ fn impl_edit_breakpoint(
|
||||
}
|
||||
};
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user