debugger: Allow users to include PickProcessId in debug tasks and resolve Pid (#42913)
Closes #33286 This PR adds support for Zed's `$ZED_PICK_PID` command in debug configurations, which allows users to select a process to attach to at debug time. When this variable is present in a debug configuration, Zed automatically opens a process picker modal. Follow up for this will be integrating this variable in the task system instead of just the debug configuration system. Release Notes: - Added `$ZED_PICK_PID` variable for debug configurations, allowing users to select which process to attach the debugger to at runtime --------- Co-authored-by: Remco Smits <djsmits12@gmail.com>
This commit is contained in:
co-authored by
Remco Smits
parent
e033829ef2
commit
56401fc99c
@@ -68,7 +68,11 @@ impl TryFrom<VsCodeDebugTaskFile> for DebugTaskFile {
|
||||
VariableName::RelativeFile.to_string(),
|
||||
),
|
||||
("file".to_owned(), VariableName::File.to_string()),
|
||||
]));
|
||||
]))
|
||||
.with_commands([(
|
||||
"pickMyProcess".to_owned(),
|
||||
VariableName::PickProcessId.to_string(),
|
||||
)]);
|
||||
let templates = file
|
||||
.configurations
|
||||
.into_iter()
|
||||
@@ -96,7 +100,7 @@ fn task_type_to_adapter_name(task_type: &str) -> String {
|
||||
mod tests {
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{DebugScenario, DebugTaskFile};
|
||||
use crate::{DebugScenario, DebugTaskFile, VariableName};
|
||||
|
||||
use super::VsCodeDebugTaskFile;
|
||||
|
||||
@@ -152,4 +156,39 @@ mod tests {
|
||||
}])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_command_pickmyprocess_replacement() {
|
||||
let raw = r#"
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Attach to Process",
|
||||
"request": "attach",
|
||||
"type": "cppdbg",
|
||||
"processId": "${command:pickMyProcess}"
|
||||
}
|
||||
]
|
||||
}
|
||||
"#;
|
||||
let parsed: VsCodeDebugTaskFile =
|
||||
serde_json_lenient::from_str(raw).expect("deserializing launch.json");
|
||||
let zed = DebugTaskFile::try_from(parsed).expect("converting to Zed debug templates");
|
||||
|
||||
let expected_placeholder = format!("${{{}}}", VariableName::PickProcessId);
|
||||
pretty_assertions::assert_eq!(
|
||||
zed,
|
||||
DebugTaskFile(vec![DebugScenario {
|
||||
label: "Attach to Process".into(),
|
||||
adapter: "CodeLLDB".into(),
|
||||
config: json!({
|
||||
"request": "attach",
|
||||
"processId": expected_placeholder,
|
||||
}),
|
||||
tcp_connection: None,
|
||||
build: None
|
||||
}])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user