summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Sharshakov2021-09-26 07:24:58 +0000
committerDmitry Sharshakov2021-09-26 07:24:58 +0000
commit0e51e5fbaf6eeffa25b8660b96f2486174671492 (patch)
treea76212d795705f3af039ff6de409bf5ec98be856
parentbf53aff27d2d90b41bab01f4d628f0bd9fbcd589 (diff)
editor: support setExceptionBreakpoints
-rw-r--r--helix-dap/src/client.rs13
-rw-r--r--helix-dap/src/types.rs23
-rw-r--r--helix-term/src/commands.rs2
-rw-r--r--helix-term/src/commands/dap.rs33
-rw-r--r--helix-term/src/keymap.rs2
5 files changed, 73 insertions, 0 deletions
diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs
index 2ae82422..8dd41868 100644
--- a/helix-dap/src/client.rs
+++ b/helix-dap/src/client.rs
@@ -399,4 +399,17 @@ impl Client {
self.request::<requests::Evaluate>(args).await
}
+
+ pub async fn set_exception_breakpoints(
+ &mut self,
+ filters: Vec<String>,
+ ) -> Result<Option<Vec<Breakpoint>>> {
+ let args = requests::SetExceptionBreakpointsArguments { filters };
+
+ let response = self
+ .request::<requests::SetExceptionBreakpoints>(args)
+ .await;
+
+ Ok(response.ok().map(|r| r.breakpoints).unwrap_or_default())
+ }
}
diff --git a/helix-dap/src/types.rs b/helix-dap/src/types.rs
index 3af29922..5430771f 100644
--- a/helix-dap/src/types.rs
+++ b/helix-dap/src/types.rs
@@ -515,6 +515,29 @@ pub mod requests {
type Result = EvaluateResponse;
const COMMAND: &'static str = "evaluate";
}
+
+ #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
+ #[serde(rename_all = "camelCase")]
+ pub struct SetExceptionBreakpointsArguments {
+ pub filters: Vec<String>,
+ // pub filterOptions: Option<Vec<ExceptionFilterOptions>>, // needs capability
+ // pub exceptionOptions: Option<Vec<ExceptionOptions>>, // needs capability
+ }
+
+ #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)]
+ #[serde(rename_all = "camelCase")]
+ pub struct SetExceptionBreakpointsResponse {
+ pub breakpoints: Option<Vec<Breakpoint>>,
+ }
+
+ #[derive(Debug)]
+ pub enum SetExceptionBreakpoints {}
+
+ impl Request for SetExceptionBreakpoints {
+ type Arguments = SetExceptionBreakpointsArguments;
+ type Result = SetExceptionBreakpointsResponse;
+ const COMMAND: &'static str = "setExceptionBreakpoints";
+ }
}
// Events
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index acaba6d6..f3f62d6b 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -335,6 +335,8 @@ impl Command {
dap_edit_log, "Edit log message of the breakpoint on the current line",
dap_switch_thread, "Switch current thread",
dap_switch_stack_frame, "Switch stack frame",
+ dap_enable_exceptions, "Enable exception breakpoints",
+ dap_disable_exceptions, "Disable exception breakpoints",
shell_pipe, "Pipe selections through shell command",
shell_pipe_to, "Pipe selections into shell command, ignoring command output",
shell_insert_output, "Insert output of shell command before each selection",
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index 3fb990c2..65a0d33f 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -513,6 +513,39 @@ pub fn dap_terminate(cx: &mut Context) {
cx.editor.debugger = None;
}
+pub fn dap_enable_exceptions(cx: &mut Context) {
+ let debugger = match &mut cx.editor.debugger {
+ Some(debugger) => debugger,
+ None => return,
+ };
+
+ let filters = match &debugger.capabilities().exception_breakpoint_filters {
+ Some(filters) => filters.clone(),
+ None => return,
+ };
+
+ if let Err(e) = block_on(
+ debugger.set_exception_breakpoints(filters.iter().map(|f| f.filter.clone()).collect()),
+ ) {
+ cx.editor
+ .set_error(format!("Failed to set up exception breakpoints: {:?}", e));
+ return;
+ }
+}
+
+pub fn dap_disable_exceptions(cx: &mut Context) {
+ let debugger = match &mut cx.editor.debugger {
+ Some(debugger) => debugger,
+ None => return,
+ };
+
+ if let Err(e) = block_on(debugger.set_exception_breakpoints(vec![])) {
+ cx.editor
+ .set_error(format!("Failed to set up exception breakpoints: {:?}", e));
+ return;
+ }
+}
+
pub fn dap_edit_condition(cx: &mut Context) {
if let Some((pos, mut bp)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
let callback = Box::pin(async move {
diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs
index 77bb187c..e344457c 100644
--- a/helix-term/src/keymap.rs
+++ b/helix-term/src/keymap.rs
@@ -557,6 +557,8 @@ impl Default for Keymaps {
"f" => dap_switch_stack_frame,
// sl, sb
},
+ "e" => dap_enable_exceptions,
+ "E" => dap_disable_exceptions,
},
"w" => { "Window"
"C-w" | "w" => rotate_view,