on master help sign in
dap: Always edit breakpoints on the correct document
commitb55ca8fdb843972ee11f73e9e32b966541da4ba8 authorBlaž Hrastnik <blaz@mxxn.io> dateMon 22 Nov 2021, 11:22 (5 years ago) parent0eadeab
1 file changed+13−31
helix-term/src/commands/dap.rs+13−31
helix-term/src/commands/dap.rs+13−31
@@ -353,7 +353,7 @@ fn debug_parameter_prompt(
353353 format!("{}: ", name).into(),
354354 None,
355355 completer,
356− move |cx: &mut crate::compositor::Context, input: &str, event: PromptEvent| {
356+ move |cx, input: &str, event: PromptEvent| {
357357 if event != PromptEvent::Validate {
358358 return;
359359 }
@@ -634,6 +634,10 @@ pub fn dap_disable_exceptions(cx: &mut Context) {
634634// we also might be editing a breakpoint in a document that's no longer focused
635635pub fn dap_edit_condition(cx: &mut Context) {
636636 if let Some((pos, breakpoint)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
637+ let path = match doc!(cx.editor).path() {
638+ Some(path) => path.clone(),
639+ None => return,
640+ };
637641 let callback = Box::pin(async move {
638642 let call: Callback =
639643 Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| {
@@ -641,25 +645,12 @@ pub fn dap_edit_condition(cx: &mut Context) {
641645 "condition:".into(),
642646 None,
643647 |_input: &str| Vec::new(),
644− move |cx: &mut crate::compositor::Context,
645− input: &str,
646− event: PromptEvent| {
648+ move |cx, input: &str, event: PromptEvent| {
647649 if event != PromptEvent::Validate {
648650 return;
649651 }
650652
651− let doc = doc!(cx.editor);
652− let path = match doc.path() {
653− Some(path) => path,
654− None => {
655− cx.editor.set_status(
656− "Can't edit breakpoint: document has no path".to_owned(),
657− );
658− return;
659− }
660− };
661−
662− let breakpoints = &mut cx.editor.breakpoints.get_mut(path).unwrap();
653+ let breakpoints = &mut cx.editor.breakpoints.get_mut(&path).unwrap();
663654 breakpoints[pos].condition = match input {
664655 "" => None,
665656 input => Some(input.to_owned()),
@@ -711,6 +702,10 @@ pub fn dap_edit_condition(cx: &mut Context) {
711702
712703pub fn dap_edit_log(cx: &mut Context) {
713704 if let Some((pos, breakpoint)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
705+ let path = match doc!(cx.editor).path() {
706+ Some(path) => path.clone(),
707+ None => return,
708+ };
714709 let callback = Box::pin(async move {
715710 let call: Callback =
716711 Box::new(move |_editor: &mut Editor, compositor: &mut Compositor| {
@@ -718,25 +713,12 @@ pub fn dap_edit_log(cx: &mut Context) {
718713 "log-message:".into(),
719714 None,
720715 |_input: &str| Vec::new(),
721− move |cx: &mut crate::compositor::Context,
722− input: &str,
723− event: PromptEvent| {
716+ move |cx, input: &str, event: PromptEvent| {
724717 if event != PromptEvent::Validate {
725718 return;
726719 }
727720
728− let doc = doc!(cx.editor);
729− let path = match doc.path() {
730− Some(path) => path,
731− None => {
732− cx.editor.set_status(
733− "Can't edit breakpoint: document has no path".to_owned(),
734− );
735− return;
736− }
737− };
738−
739− let breakpoints = &mut cx.editor.breakpoints.get_mut(path).unwrap();
721+ let breakpoints = &mut cx.editor.breakpoints.get_mut(&path).unwrap();
740722 breakpoints[pos].log_message = match input {
741723 "" => None,
742724 input => Some(input.to_owned()),