@@ -1,6 +1,8 @@
1use super::{align_view, Align, Context, Editor};
1use super::{align_view, Align, Context, Editor};
2use crate::{
2use crate::{
4+ compositor::Compositor,
4 ui::{FilePicker, Picker, Prompt, PromptEvent},
6 ui::{FilePicker, Picker, Prompt, PromptEvent},
6use helix_core::Selection;
8use helix_core::Selection;
@@ -479,69 +481,79 @@ pub fn dap_terminate(cx: &mut Context) {
480pub fn dap_edit_condition(cx: &mut Context) {
482pub fn dap_edit_condition(cx: &mut Context) {
481 if let Some((pos, mut bp)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
483 if let Some((pos, mut bp)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
484+ let callback = Box::pin(async move {
485+ let call: Callback =
486+ Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| {
482− let condition = bp.condition.clone();
487+ let condition = bp.condition.clone();
483− let prompt = Prompt::new(
488+ let prompt = Prompt::new(
484− "condition: ".into(),
489+ "condition: ".into(),
486− |_input: &str| Vec::new(),
491+ |_input: &str| Vec::new(),
487− move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
492+ move |cx: &mut crate::compositor::Context,
494+ event: PromptEvent| {
488− if event != PromptEvent::Validate {
495+ if event != PromptEvent::Validate {
492− let (_, doc) = current!(cx.editor);
499+ let (_, doc) = current!(cx.editor);
493− let path = match doc.path() {
500+ let path = match doc.path() {
494− Some(path) => path.to_path_buf(),
501+ Some(path) => path.to_path_buf(),
495− None => {
502+ None => {
496− cx.editor
503+ cx.editor.set_status(
497− .set_status("Can't edit breakpoint: document has no path".to_owned());
504+ "Can't edit breakpoint: document has no path".to_owned(),
502− let breakpoints = cx.editor.breakpoints.entry(path.clone()).or_default();
511+ cx.editor.breakpoints.entry(path.clone()).or_default();
503− breakpoints.remove(pos);
512+ breakpoints.remove(pos);
504− bp.condition = match input {
513+ bp.condition = match input {
505− "" => None,
514+ "" => None,
506− input => Some(input.to_owned()),
515+ input => Some(input.to_owned()),
508− breakpoints.push(bp.clone());
517+ breakpoints.push(bp.clone());
510− if let Some(debugger) = &mut cx.editor.debugger {
519+ if let Some(debugger) = &mut cx.editor.debugger {
511− // TODO: handle capabilities correctly again, by filterin breakpoints when emitting
520+ // TODO: handle capabilities correctly again, by filterin breakpoints when emitting
512− // if breakpoint.condition.is_some()
521+ // if breakpoint.condition.is_some()
513− // && !debugger
522+ // && !debugger
514− // .caps
523+ // .caps
515− // .as_ref()
524+ // .as_ref()
516− // .unwrap()
525+ // .unwrap()
517− // .supports_conditional_breakpoints
526+ // .supports_conditional_breakpoints
518− // .unwrap_or_default()
527+ // .unwrap_or_default()
520− // bail!(
529+ // bail!(
521− // "Can't edit breakpoint: debugger does not support conditional breakpoints"
530+ // "Can't edit breakpoint: debugger does not support conditional breakpoints"
524− // if breakpoint.log_message.is_some()
533+ // if breakpoint.log_message.is_some()
525− // && !debugger
534+ // && !debugger
526− // .caps
535+ // .caps
527− // .as_ref()
536+ // .as_ref()
528− // .unwrap()
537+ // .unwrap()
529− // .supports_log_points
538+ // .supports_log_points
530− // .unwrap_or_default()
539+ // .unwrap_or_default()
532− // bail!("Can't edit breakpoint: debugger does not support logpoints")
541+ // bail!("Can't edit breakpoint: debugger does not support logpoints")
534− let request = debugger.set_breakpoints(path, breakpoints.clone());
543+ let request = debugger.set_breakpoints(path, breakpoints.clone());
535− if let Err(e) = block_on(request) {
544+ if let Err(e) = block_on(request) {
536− cx.editor
545+ cx.editor
537− .set_status(format!("Failed to set breakpoints: {:?}", e))
546+ .set_status(format!("Failed to set breakpoints: {:?}", e))
541− condition,
550+ condition,
544− cx.push_layer(Box::new(prompt));
552+ compositor.push(Box::new(prompt));
556+ cx.jobs.callback(callback);