on master help sign in
editor: support setExceptionBreakpoints
0e51e5fDmitry Sharshakov
helix-dap/src/client.rs+13
@@ -399,4 +399,17 @@ impl Client {
399
399
400 self.request::<requests::Evaluate>(args).await
400 self.request::<requests::Evaluate>(args).await
401 }
401 }
402+
403+ pub async fn set_exception_breakpoints(
404+ &mut self,
405+ filters: Vec<String>,
406+ ) -> Result<Option<Vec<Breakpoint>>> {
407+ let args = requests::SetExceptionBreakpointsArguments { filters };
408+
409+ let response = self
410+ .request::<requests::SetExceptionBreakpoints>(args)
411+ .await;
412+
413+ Ok(response.ok().map(|r| r.breakpoints).unwrap_or_default())
414+ }
402}
415}
helix-dap/src/types.rs+23
@@ -515,6 +515,29 @@ pub mod requests {
515 type Result = EvaluateResponse;
515 type Result = EvaluateResponse;
516 const COMMAND: &'static str = "evaluate";
516 const COMMAND: &'static str = "evaluate";
517 }
517 }
518+
519+ #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
520+ #[serde(rename_all = "camelCase")]
521+ pub struct SetExceptionBreakpointsArguments {
522+ pub filters: Vec<String>,
523+ // pub filterOptions: Option<Vec<ExceptionFilterOptions>>, // needs capability
524+ // pub exceptionOptions: Option<Vec<ExceptionOptions>>, // needs capability
525+ }
526+
527+ #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
528+ #[serde(rename_all = "camelCase")]
529+ pub struct SetExceptionBreakpointsResponse {
530+ pub breakpoints: Option<Vec<Breakpoint>>,
531+ }
532+
533+ #[derive(Debug)]
534+ pub enum SetExceptionBreakpoints {}
535+
536+ impl Request for SetExceptionBreakpoints {
537+ type Arguments = SetExceptionBreakpointsArguments;
538+ type Result = SetExceptionBreakpointsResponse;
539+ const COMMAND: &'static str = "setExceptionBreakpoints";
540+ }
518}
541}
519
542
520// Events
543// Events
helix-term/src/commands.rs+2
@@ -335,6 +335,8 @@ impl Command {
335 dap_edit_log, "Edit log message of the breakpoint on the current line",
335 dap_edit_log, "Edit log message of the breakpoint on the current line",
336 dap_switch_thread, "Switch current thread",
336 dap_switch_thread, "Switch current thread",
337 dap_switch_stack_frame, "Switch stack frame",
337 dap_switch_stack_frame, "Switch stack frame",
338+ dap_enable_exceptions, "Enable exception breakpoints",
339+ dap_disable_exceptions, "Disable exception breakpoints",
338 shell_pipe, "Pipe selections through shell command",
340 shell_pipe, "Pipe selections through shell command",
339 shell_pipe_to, "Pipe selections into shell command, ignoring command output",
341 shell_pipe_to, "Pipe selections into shell command, ignoring command output",
340 shell_insert_output, "Insert output of shell command before each selection",
342 shell_insert_output, "Insert output of shell command before each selection",
helix-term/src/commands/dap.rs+33
@@ -513,6 +513,39 @@ pub fn dap_terminate(cx: &mut Context) {
513 cx.editor.debugger = None;
513 cx.editor.debugger = None;
514}
514}
515
515
516+pub fn dap_enable_exceptions(cx: &mut Context) {
517+ let debugger = match &mut cx.editor.debugger {
518+ Some(debugger) => debugger,
519+ None => return,
520+ };
521+
522+ let filters = match &debugger.capabilities().exception_breakpoint_filters {
523+ Some(filters) => filters.clone(),
524+ None => return,
525+ };
526+
527+ if let Err(e) = block_on(
528+ debugger.set_exception_breakpoints(filters.iter().map(|f| f.filter.clone()).collect()),
529+ ) {
530+ cx.editor
531+ .set_error(format!("Failed to set up exception breakpoints: {:?}", e));
532+ return;
533+ }
534+}
535+
536+pub fn dap_disable_exceptions(cx: &mut Context) {
537+ let debugger = match &mut cx.editor.debugger {
538+ Some(debugger) => debugger,
539+ None => return,
540+ };
541+
542+ if let Err(e) = block_on(debugger.set_exception_breakpoints(vec![])) {
543+ cx.editor
544+ .set_error(format!("Failed to set up exception breakpoints: {:?}", e));
545+ return;
546+ }
547+}
548+
516pub fn dap_edit_condition(cx: &mut Context) {
549pub fn dap_edit_condition(cx: &mut Context) {
517 if let Some((pos, mut bp)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
550 if let Some((pos, mut bp)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
518 let callback = Box::pin(async move {
551 let callback = Box::pin(async move {
helix-term/src/keymap.rs+2
@@ -557,6 +557,8 @@ impl Default for Keymaps {
557 "f" => dap_switch_stack_frame,
557 "f" => dap_switch_stack_frame,
558 // sl, sb
558 // sl, sb
559 },
559 },
560+ "e" => dap_enable_exceptions,
561+ "E" => dap_disable_exceptions,
560 },
562 },
561 "w" => { "Window"
563 "w" => { "Window"
562 "C-w" | "w" => rotate_view,
564 "C-w" | "w" => rotate_view,