diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index a56110cb4780c9..5e47c5ee85d6ff 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -115,8 +115,20 @@ impl DebugPanel { match event { Events::Initialized(_) => { let client = this.debug_client_by_id(*client_id, cx); - cx.spawn(|_, _| async move { - // TODO: send all the current breakpoints + + cx.spawn(|this, mut cx| async move { + let task = this.update(&mut cx, |this, cx| { + this.workspace.update(cx, |workspace, cx| { + workspace.project().update(cx, |project, cx| { + let client = client.clone(); + + project.send_breakpoints(client, cx) + }) + }) + })??; + + task.await?; + client.configuration_done().await }) .detach_and_log_err(cx); diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 77dc8afdd4d706..455e7ae3e55b80 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -1059,6 +1059,57 @@ impl Project { }) } + pub fn send_breakpoints( + &self, + client: Arc, + cx: &mut ModelContext, + ) -> Task> { + cx.spawn(|project, mut cx| async move { + let task = project.update(&mut cx, |project, cx| { + let mut tasks = Vec::new(); + + for (buffer_id, breakpoints) in project.breakpoints.iter() { + let res = maybe!({ + let buffer = project.buffer_for_id(*buffer_id)?; + + let project_path = buffer.read(cx).project_path(cx)?; + let worktree = project.worktree_for_id(project_path.worktree_id, cx)?; + let path = worktree.read(cx).absolutize(&project_path.path).ok()?; + + Some((path, breakpoints)) + }); + + if let Some((path, breakpoints)) = res { + tasks.push( + client.set_breakpoints( + path, + Some( + breakpoints + .iter() + .map(|b| SourceBreakpoint { + line: b.row as u64, + condition: None, + hit_condition: None, + log_message: None, + column: None, + mode: None, + }) + .collect::>(), + ), + ), + ); + } + } + + try_join_all(tasks) + })?; + + task.await?; + + Ok(()) + }) + } + pub fn start_debug_adapter_client( &mut self, debug_task: task::ResolvedTask,