debugger: Mark DapLocator::create_scenario as an async function (#32680)

Paves way for locators in extensions.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-06-13 13:19:03 +02:00 committed by GitHub
parent 2c491d3a66
commit d5b8c21a75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 290 additions and 218 deletions

View file

@ -5801,9 +5801,11 @@ impl Editor {
tasks.column,
)),
});
let debug_scenarios = editor.update(cx, |editor, cx| {
editor.debug_scenarios(&resolved_tasks, &buffer, cx)
})?;
let debug_scenarios = editor
.update(cx, |editor, cx| {
editor.debug_scenarios(&resolved_tasks, &buffer, cx)
})?
.await;
anyhow::Ok((resolved_tasks, debug_scenarios, task_context))
}
})
@ -5859,7 +5861,7 @@ impl Editor {
resolved_tasks: &Option<ResolvedTasks>,
buffer: &Entity<Buffer>,
cx: &mut App,
) -> Vec<task::DebugScenario> {
) -> Task<Vec<task::DebugScenario>> {
if cx.has_flag::<DebuggerFeatureFlag>() {
maybe!({
let project = self.project.as_ref()?;
@ -5877,21 +5879,27 @@ impl Editor {
dap_store.update(cx, |dap_store, cx| {
for (_, task) in &resolved_tasks.templates {
if let Some(scenario) = dap_store.debug_scenario_for_build_task(
let maybe_scenario = dap_store.debug_scenario_for_build_task(
task.original_task().clone(),
debug_adapter.clone().into(),
task.display_label().to_owned().into(),
cx,
) {
scenarios.push(scenario);
}
);
scenarios.push(maybe_scenario);
}
});
Some(scenarios)
Some(cx.background_spawn(async move {
let scenarios = futures::future::join_all(scenarios)
.await
.into_iter()
.flatten()
.collect::<Vec<_>>();
scenarios
}))
})
.unwrap_or_default()
.unwrap_or_else(|| Task::ready(vec![]))
} else {
vec![]
Task::ready(vec![])
}
}