@@ -557,6 +557,84 @@ pub fn dap_edit_condition(cx: &mut Context) {
557557 }
558558}
559559
560+pub fn dap_edit_log(cx: &mut Context) {
561+ if let Some((pos, mut bp)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
562+ let callback = Box::pin(async move {
563+ let call: Callback =
564+ Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| {
565+ let log_message = bp.log_message.clone();
566+ let prompt = Prompt::new(
567+ "log message: ".into(),
568+ None,
569+ |_input: &str| Vec::new(),
570+ move |cx: &mut crate::compositor::Context,
571+ input: &str,
572+ event: PromptEvent| {
573+ if event != PromptEvent::Validate {
574+ return;
575+ }
576+
577+ let (_, doc) = current!(cx.editor);
578+ let path = match doc.path() {
579+ Some(path) => path.to_path_buf(),
580+ None => {
581+ cx.editor.set_status(
582+ "Can't edit breakpoint: document has no path".to_owned(),
583+ );
584+ return;
585+ }
586+ };
587+
588+ let breakpoints =
589+ cx.editor.breakpoints.entry(path.clone()).or_default();
590+ breakpoints.remove(pos);
591+ bp.log_message = match input {
592+ "" => None,
593+ input => Some(input.to_owned()),
594+ };
595+ breakpoints.push(bp.clone());
596+
597+ if let Some(debugger) = &mut cx.editor.debugger {
598+ // TODO: handle capabilities correctly again, by filterin breakpoints when emitting
599+ // if breakpoint.condition.is_some()
600+ // && !debugger
601+ // .caps
602+ // .as_ref()
603+ // .unwrap()
604+ // .supports_conditional_breakpoints
605+ // .unwrap_or_default()
606+ // {
607+ // bail!(
608+ // "Can't edit breakpoint: debugger does not support conditional breakpoints"
609+ // )
610+ // }
611+ // if breakpoint.log_message.is_some()
612+ // && !debugger
613+ // .caps
614+ // .as_ref()
615+ // .unwrap()
616+ // .supports_log_points
617+ // .unwrap_or_default()
618+ // {
619+ // bail!("Can't edit breakpoint: debugger does not support logpoints")
620+ // }
621+ let request = debugger.set_breakpoints(path, breakpoints.clone());
622+ if let Err(e) = block_on(request) {
623+ cx.editor
624+ .set_status(format!("Failed to set breakpoints: {:?}", e))
625+ }
626+ }
627+ },
628+ log_message,
629+ );
630+ compositor.push(Box::new(prompt));
631+ });
632+ Ok(call)
633+ });
634+ cx.jobs.callback(callback);
635+ }
636+}
637+
560638pub fn dap_switch_thread(cx: &mut Context) {
561639 thread_picker(cx, |editor, thread| {
562640 block_on(select_thread_id(editor, thread.id, true));