Skip to content

Commit

Permalink
Fix send all breakpoints when toggling breakpoints
Browse files Browse the repository at this point in the history
We now send all the breakpoints for the current buffer when toggling one breakpoint.

Co-Authored-By: Anthony Eid <[email protected]>
  • Loading branch information
RemcoSmitsDev and Anthony-Eid committed Jul 12, 2024
1 parent 014ffbc commit 8adc489
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 28 deletions.
4 changes: 2 additions & 2 deletions crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
35 changes: 9 additions & 26 deletions crates/project/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1200,18 +1200,9 @@ impl Project {
row: BufferRow,
cx: &mut ModelContext<Self>,
) {
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
Expand All @@ -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: row });
}

let clients = self
Expand All @@ -1232,23 +1223,15 @@ impl Project {
})
.collect::<Vec<_>>();

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)
Expand Down

0 comments on commit 8adc489

Please sign in to comment.