Skip to content

Commit 014ffbc

Browse files
Send the initial breakpoints from the project
We now send the initial breakpoints that we created before the debug adapter was running. Co-Authored-By: Anthony Eid <[email protected]>
1 parent 68dd3c9 commit 014ffbc

File tree

2 files changed

+65
-2
lines changed

2 files changed

+65
-2
lines changed

crates/debugger_ui/src/debugger_panel.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,20 @@ impl DebugPanel {
115115
match event {
116116
Events::Initialized(_) => {
117117
let client = this.debug_client_by_id(*client_id, cx);
118-
cx.spawn(|_, _| async move {
119-
// TODO: send all the current breakpoints
118+
119+
cx.spawn(|this, mut cx| async move {
120+
let task = this.update(&mut cx, |this, cx| {
121+
this.workspace.update(cx, |workspace, cx| {
122+
workspace.project().update(cx, |project, cx| {
123+
let client = client.clone();
124+
125+
project.send_breakpoints(client, cx)
126+
})
127+
})
128+
})??;
129+
130+
task.await?;
131+
120132
client.configuration_done().await
121133
})
122134
.detach_and_log_err(cx);

crates/project/src/project.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,57 @@ impl Project {
10591059
})
10601060
}
10611061

1062+
pub fn send_breakpoints(
1063+
&self,
1064+
client: Arc<DebugAdapterClient>,
1065+
cx: &mut ModelContext<Self>,
1066+
) -> Task<Result<()>> {
1067+
cx.spawn(|project, mut cx| async move {
1068+
let task = project.update(&mut cx, |project, cx| {
1069+
let mut tasks = Vec::new();
1070+
1071+
for (buffer_id, breakpoints) in project.breakpoints.iter() {
1072+
let res = maybe!({
1073+
let buffer = project.buffer_for_id(*buffer_id)?;
1074+
1075+
let project_path = buffer.read(cx).project_path(cx)?;
1076+
let worktree = project.worktree_for_id(project_path.worktree_id, cx)?;
1077+
let path = worktree.read(cx).absolutize(&project_path.path).ok()?;
1078+
1079+
Some((path, breakpoints))
1080+
});
1081+
1082+
if let Some((path, breakpoints)) = res {
1083+
tasks.push(
1084+
client.set_breakpoints(
1085+
path,
1086+
Some(
1087+
breakpoints
1088+
.iter()
1089+
.map(|b| SourceBreakpoint {
1090+
line: b.row as u64,
1091+
condition: None,
1092+
hit_condition: None,
1093+
log_message: None,
1094+
column: None,
1095+
mode: None,
1096+
})
1097+
.collect::<Vec<_>>(),
1098+
),
1099+
),
1100+
);
1101+
}
1102+
}
1103+
1104+
try_join_all(tasks)
1105+
})?;
1106+
1107+
task.await?;
1108+
1109+
Ok(())
1110+
})
1111+
}
1112+
10621113
pub fn start_debug_adapter_client(
10631114
&mut self,
10641115
debug_task: task::ResolvedTask,

0 commit comments

Comments
 (0)