Clear breakpoints action (#27254)

This PR adds an action that clears all breakpoints and notifies any
active DAPs.

todo
- [x] Implement clear functionality
- [x] Write an integration test for this

Release Notes:

- N/A *or* Added/Fixed/Improved ...

---------

Co-authored-by: Piotr Osiewicz <peterosiewicz@gmail.com>
This commit is contained in:
Anthony Eid 2025-03-21 16:18:08 -04:00 committed by GitHub
parent 16ad7424d6
commit 739f45eb23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 209 additions and 5 deletions

View file

@ -237,6 +237,19 @@ impl LocalMode {
.on_request::<dap::requests::Initialize, _>(move |_, _| Ok(caps.clone()))
.await;
let paths = cx.update(|cx| session.breakpoint_store.read(cx).breakpoint_paths()).expect("Breakpoint store should exist in all tests that start debuggers");
session.client.on_request::<dap::requests::SetBreakpoints, _>(move |_, args| {
let p = Arc::from(Path::new(&args.source.path.unwrap()));
if !paths.contains(&p) {
panic!("Sent breakpoints for path without any")
}
Ok(dap::SetBreakpointsResponse {
breakpoints: Vec::default(),
})
}).await;
match config.request.clone() {
dap::DebugRequestType::Launch if fail => {
session
@ -307,6 +320,34 @@ impl LocalMode {
})
}
fn unset_breakpoints_from_paths(&self, paths: &Vec<Arc<Path>>, cx: &mut App) -> Task<()> {
let tasks: Vec<_> = paths
.into_iter()
.map(|path| {
self.request(
dap_command::SetBreakpoints {
source: client_source(path),
source_modified: None,
breakpoints: vec![],
},
cx.background_executor().clone(),
)
})
.collect();
cx.background_spawn(async move {
futures::future::join_all(tasks)
.await
.iter()
.for_each(|res| match res {
Ok(_) => {}
Err(err) => {
log::warn!("Set breakpoints request failed: {}", err);
}
});
})
}
fn send_breakpoints_from_path(
&self,
abs_path: Arc<Path>,
@ -752,6 +793,14 @@ impl Session {
.detach();
};
}
BreakpointStoreEvent::BreakpointsCleared(paths) => {
if let Some(local) = (!this.ignore_breakpoints)
.then(|| this.as_local_mut())
.flatten()
{
local.unset_breakpoints_from_paths(paths, cx).detach();
}
}
BreakpointStoreEvent::ActiveDebugLineChanged => {}
})
.detach();