aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-11-22 02:22:08 +0000
committerBlaž Hrastnik2021-11-22 02:22:08 +0000
commitb55ca8fdb843972ee11f73e9e32b966541da4ba8 (patch)
treeae867b90cc33f8bbe7cb3ec0687fc8e4a239293a /helix-term
parent0eadeab8c7c3f1ddc794661782ebbe19ddf5311e (diff)
dap: Always edit breakpoints on the correct document
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands/dap.rs44
1 files changed, 13 insertions, 31 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index e117baff..441348f6 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -353,7 +353,7 @@ fn debug_parameter_prompt(
format!("{}: ", name).into(),
None,
completer,
- move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
+ move |cx, input: &str, event: PromptEvent| {
if event != PromptEvent::Validate {
return;
}
@@ -634,6 +634,10 @@ pub fn dap_disable_exceptions(cx: &mut Context) {
// we also might be editing a breakpoint in a document that's no longer focused
pub fn dap_edit_condition(cx: &mut Context) {
if let Some((pos, breakpoint)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
+ let path = match doc!(cx.editor).path() {
+ Some(path) => path.clone(),
+ None => return,
+ };
let callback = Box::pin(async move {
let call: Callback =
Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| {
@@ -641,25 +645,12 @@ pub fn dap_edit_condition(cx: &mut Context) {
"condition:".into(),
None,
|_input: &str| Vec::new(),
- move |cx: &mut crate::compositor::Context,
- input: &str,
- event: PromptEvent| {
+ move |cx, input: &str, event: PromptEvent| {
if event != PromptEvent::Validate {
return;
}
- let doc = doc!(cx.editor);
- let path = match doc.path() {
- Some(path) => path,
- None => {
- cx.editor.set_status(
- "Can't edit breakpoint: document has no path".to_owned(),
- );
- return;
- }
- };
-
- let breakpoints = &mut cx.editor.breakpoints.get_mut(path).unwrap();
+ let breakpoints = &mut cx.editor.breakpoints.get_mut(&path).unwrap();
breakpoints[pos].condition = match input {
"" => None,
input => Some(input.to_owned()),
@@ -711,6 +702,10 @@ pub fn dap_edit_condition(cx: &mut Context) {
pub fn dap_edit_log(cx: &mut Context) {
if let Some((pos, breakpoint)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
+ let path = match doc!(cx.editor).path() {
+ Some(path) => path.clone(),
+ None => return,
+ };
let callback = Box::pin(async move {
let call: Callback =
Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| {
@@ -718,25 +713,12 @@ pub fn dap_edit_log(cx: &mut Context) {
"log-message:".into(),
None,
|_input: &str| Vec::new(),
- move |cx: &mut crate::compositor::Context,
- input: &str,
- event: PromptEvent| {
+ move |cx, input: &str, event: PromptEvent| {
if event != PromptEvent::Validate {
return;
}
- let doc = doc!(cx.editor);
- let path = match doc.path() {
- Some(path) => path,
- None => {
- cx.editor.set_status(
- "Can't edit breakpoint: document has no path".to_owned(),
- );
- return;
- }
- };
-
- let breakpoints = &mut cx.editor.breakpoints.get_mut(path).unwrap();
+ let breakpoints = &mut cx.editor.breakpoints.get_mut(&path).unwrap();
breakpoints[pos].log_message = match input {
"" => None,
input => Some(input.to_owned()),