|
|
@ -1,6 +1,8 @@
|
|
|
|
use super::{align_view, Align, Context, Editor};
|
|
|
|
use super::{align_view, Align, Context, Editor};
|
|
|
|
use crate::{
|
|
|
|
use crate::{
|
|
|
|
commands,
|
|
|
|
commands,
|
|
|
|
|
|
|
|
compositor::Compositor,
|
|
|
|
|
|
|
|
job::Callback,
|
|
|
|
ui::{FilePicker, Picker, Prompt, PromptEvent},
|
|
|
|
ui::{FilePicker, Picker, Prompt, PromptEvent},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use helix_core::Selection;
|
|
|
|
use helix_core::Selection;
|
|
|
@ -479,69 +481,79 @@ pub fn dap_terminate(cx: &mut Context) {
|
|
|
|
|
|
|
|
|
|
|
|
pub fn dap_edit_condition(cx: &mut Context) {
|
|
|
|
pub fn dap_edit_condition(cx: &mut Context) {
|
|
|
|
if let Some((pos, mut bp)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
|
|
|
|
if let Some((pos, mut bp)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
|
|
|
|
let condition = bp.condition.clone();
|
|
|
|
let callback = Box::pin(async move {
|
|
|
|
let prompt = Prompt::new(
|
|
|
|
let call: Callback =
|
|
|
|
"condition: ".into(),
|
|
|
|
Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| {
|
|
|
|
None,
|
|
|
|
let condition = bp.condition.clone();
|
|
|
|
|_input: &str| Vec::new(),
|
|
|
|
let prompt = Prompt::new(
|
|
|
|
move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
|
|
|
|
"condition: ".into(),
|
|
|
|
if event != PromptEvent::Validate {
|
|
|
|
None,
|
|
|
|
return;
|
|
|
|
|_input: &str| Vec::new(),
|
|
|
|
}
|
|
|
|
move |cx: &mut crate::compositor::Context,
|
|
|
|
|
|
|
|
input: &str,
|
|
|
|
let (_, doc) = current!(cx.editor);
|
|
|
|
event: PromptEvent| {
|
|
|
|
let path = match doc.path() {
|
|
|
|
if event != PromptEvent::Validate {
|
|
|
|
Some(path) => path.to_path_buf(),
|
|
|
|
return;
|
|
|
|
None => {
|
|
|
|
}
|
|
|
|
cx.editor
|
|
|
|
|
|
|
|
.set_status("Can't edit breakpoint: document has no path".to_owned());
|
|
|
|
let (_, doc) = current!(cx.editor);
|
|
|
|
return;
|
|
|
|
let path = match doc.path() {
|
|
|
|
}
|
|
|
|
Some(path) => path.to_path_buf(),
|
|
|
|
};
|
|
|
|
None => {
|
|
|
|
|
|
|
|
cx.editor.set_status(
|
|
|
|
let breakpoints = cx.editor.breakpoints.entry(path.clone()).or_default();
|
|
|
|
"Can't edit breakpoint: document has no path".to_owned(),
|
|
|
|
breakpoints.remove(pos);
|
|
|
|
);
|
|
|
|
bp.condition = match input {
|
|
|
|
return;
|
|
|
|
"" => None,
|
|
|
|
}
|
|
|
|
input => Some(input.to_owned()),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
breakpoints.push(bp.clone());
|
|
|
|
let breakpoints =
|
|
|
|
|
|
|
|
cx.editor.breakpoints.entry(path.clone()).or_default();
|
|
|
|
if let Some(debugger) = &mut cx.editor.debugger {
|
|
|
|
breakpoints.remove(pos);
|
|
|
|
// TODO: handle capabilities correctly again, by filterin breakpoints when emitting
|
|
|
|
bp.condition = match input {
|
|
|
|
// if breakpoint.condition.is_some()
|
|
|
|
"" => None,
|
|
|
|
// && !debugger
|
|
|
|
input => Some(input.to_owned()),
|
|
|
|
// .caps
|
|
|
|
};
|
|
|
|
// .as_ref()
|
|
|
|
breakpoints.push(bp.clone());
|
|
|
|
// .unwrap()
|
|
|
|
|
|
|
|
// .supports_conditional_breakpoints
|
|
|
|
if let Some(debugger) = &mut cx.editor.debugger {
|
|
|
|
// .unwrap_or_default()
|
|
|
|
// TODO: handle capabilities correctly again, by filterin breakpoints when emitting
|
|
|
|
// {
|
|
|
|
// if breakpoint.condition.is_some()
|
|
|
|
// bail!(
|
|
|
|
// && !debugger
|
|
|
|
// "Can't edit breakpoint: debugger does not support conditional breakpoints"
|
|
|
|
// .caps
|
|
|
|
// )
|
|
|
|
// .as_ref()
|
|
|
|
// }
|
|
|
|
// .unwrap()
|
|
|
|
// if breakpoint.log_message.is_some()
|
|
|
|
// .supports_conditional_breakpoints
|
|
|
|
// && !debugger
|
|
|
|
// .unwrap_or_default()
|
|
|
|
// .caps
|
|
|
|
// {
|
|
|
|
// .as_ref()
|
|
|
|
// bail!(
|
|
|
|
// .unwrap()
|
|
|
|
// "Can't edit breakpoint: debugger does not support conditional breakpoints"
|
|
|
|
// .supports_log_points
|
|
|
|
// )
|
|
|
|
// .unwrap_or_default()
|
|
|
|
// }
|
|
|
|
// {
|
|
|
|
// if breakpoint.log_message.is_some()
|
|
|
|
// bail!("Can't edit breakpoint: debugger does not support logpoints")
|
|
|
|
// && !debugger
|
|
|
|
// }
|
|
|
|
// .caps
|
|
|
|
let request = debugger.set_breakpoints(path, breakpoints.clone());
|
|
|
|
// .as_ref()
|
|
|
|
if let Err(e) = block_on(request) {
|
|
|
|
// .unwrap()
|
|
|
|
cx.editor
|
|
|
|
// .supports_log_points
|
|
|
|
.set_status(format!("Failed to set breakpoints: {:?}", e))
|
|
|
|
// .unwrap_or_default()
|
|
|
|
}
|
|
|
|
// {
|
|
|
|
}
|
|
|
|
// bail!("Can't edit breakpoint: debugger does not support logpoints")
|
|
|
|
},
|
|
|
|
// }
|
|
|
|
condition,
|
|
|
|
let request = debugger.set_breakpoints(path, breakpoints.clone());
|
|
|
|
);
|
|
|
|
if let Err(e) = block_on(request) {
|
|
|
|
|
|
|
|
cx.editor
|
|
|
|
cx.push_layer(Box::new(prompt));
|
|
|
|
.set_status(format!("Failed to set breakpoints: {:?}", e))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
condition,
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
compositor.push(Box::new(prompt));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
Ok(call)
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
cx.jobs.callback(callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|