From 8d99f9b7d2bc8b61693471dc35861c41b7595b61 Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Fri, 12 Jul 2024 21:58:18 +0200 Subject: [PATCH] Fix send all breakpoints when toggling breakpoints We now send all the breakpoints for the current buffer when toggling one breakpoint. Co-Authored-By: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com> --- crates/editor/src/editor.rs | 4 ++-- crates/project/src/project.rs | 35 +++++++++-------------------------- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 8895bf8e0e4b4e..9907a8d41326ed 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -5898,9 +5898,9 @@ impl Editor { }, ); } - + project.update(cx, |project, cx| { - project.update_breakpoint(buffer, row, cx); + project.update_breakpoint(buffer, row + 1, cx); }); cx.notify(); } diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 455e7ae3e55b80..25f02fe3b8f9d7 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1200,18 +1200,9 @@ impl Project { row: BufferRow, cx: &mut ModelContext, ) { - let buffer = buffer.read(cx); - let Some(abs_path) = maybe!({ - let project_path = buffer.project_path(cx)?; - let worktree = self.worktree_for_id(project_path.worktree_id, cx)?; - worktree.read(cx).absolutize(&project_path.path).ok() - }) else { - return; - }; - let breakpoints_for_buffer = self .breakpoints - .entry(buffer.remote_id()) + .entry(buffer.read(cx).remote_id()) .or_insert(Vec::new()); if let Some(ix) = breakpoints_for_buffer @@ -1220,7 +1211,7 @@ impl Project { { breakpoints_for_buffer.remove(ix); } else { - breakpoints_for_buffer.push(Breakpoint { row: row + 1 }); + breakpoints_for_buffer.push(Breakpoint { row }); } let clients = self @@ -1232,23 +1223,15 @@ impl Project { }) .collect::>(); + let mut tasks = Vec::new(); + for client in clients { + tasks.push(self.send_breakpoints(client, cx)); + } + cx.background_executor() .spawn(async move { - for client in clients { - client - .set_breakpoints( - abs_path.clone(), - Some(vec![SourceBreakpoint { - line: (row + 1) as u64, - condition: None, - hit_condition: None, - log_message: None, - column: None, - mode: None, - }]), - ) - .await?; - } + try_join_all(tasks).await?; + anyhow::Ok(()) }) .detach_and_log_err(cx)