debugger: Fix debug scenario's defined in debug.json not using passed in build task (#29973)

There were two bugs that caused user-defined debug scenarios from being
able to run a build task.

1. DebugRequest would be deserialized to `Attach` even when `process_id`
wasn't defined in a user's configuration file. This has been fixed by
adding our own deserializer that defaults to None if there are no fields
present instead of `Attach`, and I added tests to prevent regressions.
2. Debug scenario resolve phase never got the active buffer when
spawning a debug session from the new session modal. This has been
worked around by passing in the worktree_id of a debug scenario in the
scenario picker and the active worktree_id otherwise.

Release Notes:

- N/A
This commit is contained in:
Anthony Eid 2025-05-06 08:54:57 +02:00 committed by GitHub
parent 52ea501f4f
commit a0bfe4d293
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 97 additions and 12 deletions

View file

@ -229,10 +229,11 @@ impl Inventory {
pub fn task_template_by_label(
&self,
buffer: Option<Entity<Buffer>>,
worktree_id: Option<WorktreeId>,
label: &str,
cx: &App,
) -> Option<TaskTemplate> {
let (worktree_id, file, language) = buffer
let (buffer_worktree_id, file, language) = buffer
.map(|buffer| {
let buffer = buffer.read(cx);
let file = buffer.file().cloned();
@ -244,7 +245,7 @@ impl Inventory {
})
.unwrap_or((None, None, None));
self.list_tasks(file, language, worktree_id, cx)
self.list_tasks(file, language, worktree_id.or(buffer_worktree_id), cx)
.iter()
.find(|(_, template)| template.label == label)
.map(|val| val.1.clone())