|
|
@ -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,12 +481,17 @@ 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 callback = Box::pin(async move {
|
|
|
|
|
|
|
|
let call: Callback =
|
|
|
|
|
|
|
|
Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| {
|
|
|
|
let condition = bp.condition.clone();
|
|
|
|
let condition = bp.condition.clone();
|
|
|
|
let prompt = Prompt::new(
|
|
|
|
let prompt = Prompt::new(
|
|
|
|
"condition: ".into(),
|
|
|
|
"condition: ".into(),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
|_input: &str| Vec::new(),
|
|
|
|
|_input: &str| Vec::new(),
|
|
|
|
move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
|
|
|
|
move |cx: &mut crate::compositor::Context,
|
|
|
|
|
|
|
|
input: &str,
|
|
|
|
|
|
|
|
event: PromptEvent| {
|
|
|
|
if event != PromptEvent::Validate {
|
|
|
|
if event != PromptEvent::Validate {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -493,13 +500,15 @@ pub fn dap_edit_condition(cx: &mut Context) {
|
|
|
|
let path = match doc.path() {
|
|
|
|
let path = match doc.path() {
|
|
|
|
Some(path) => path.to_path_buf(),
|
|
|
|
Some(path) => path.to_path_buf(),
|
|
|
|
None => {
|
|
|
|
None => {
|
|
|
|
cx.editor
|
|
|
|
cx.editor.set_status(
|
|
|
|
.set_status("Can't edit breakpoint: document has no path".to_owned());
|
|
|
|
"Can't edit breakpoint: document has no path".to_owned(),
|
|
|
|
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let breakpoints = cx.editor.breakpoints.entry(path.clone()).or_default();
|
|
|
|
let breakpoints =
|
|
|
|
|
|
|
|
cx.editor.breakpoints.entry(path.clone()).or_default();
|
|
|
|
breakpoints.remove(pos);
|
|
|
|
breakpoints.remove(pos);
|
|
|
|
bp.condition = match input {
|
|
|
|
bp.condition = match input {
|
|
|
|
"" => None,
|
|
|
|
"" => None,
|
|
|
@ -540,8 +549,11 @@ pub fn dap_edit_condition(cx: &mut Context) {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
condition,
|
|
|
|
condition,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
compositor.push(Box::new(prompt));
|
|
|
|
cx.push_layer(Box::new(prompt));
|
|
|
|
});
|
|
|
|
|
|
|
|
Ok(call)
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
cx.jobs.callback(callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|