debugger: Fix DebugAdapterDelegate::worktree_root always using the first visible worktree (#32585)
Closes #32577 Release Notes: - Fixed debugger malfunctioning when using ZED_WORKTREE_ROOT env variable in multi-worktree workspaces.
This commit is contained in:
parent
1083c0ac53
commit
04223f304b
4 changed files with 45 additions and 15 deletions
|
@ -179,6 +179,19 @@ impl DebugPanel {
|
|||
cx,
|
||||
)
|
||||
});
|
||||
let worktree = worktree_id.or_else(|| {
|
||||
active_buffer
|
||||
.as_ref()
|
||||
.and_then(|buffer| buffer.read(cx).file())
|
||||
.map(|f| f.worktree_id(cx))
|
||||
});
|
||||
let Some(worktree) = worktree
|
||||
.and_then(|id| self.project.read(cx).worktree_for_id(id, cx))
|
||||
.or_else(|| self.project.read(cx).visible_worktrees(cx).next())
|
||||
else {
|
||||
log::debug!("Could not find a worktree to spawn the debug session in");
|
||||
return;
|
||||
};
|
||||
self.debug_scenario_scheduled_last = true;
|
||||
if let Some(inventory) = self
|
||||
.project
|
||||
|
@ -213,7 +226,7 @@ impl DebugPanel {
|
|||
.await?;
|
||||
dap_store
|
||||
.update(cx, |dap_store, cx| {
|
||||
dap_store.boot_session(session.clone(), definition, cx)
|
||||
dap_store.boot_session(session.clone(), definition, worktree, cx)
|
||||
})?
|
||||
.await
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue