debugger: Add args argument to debugger launch config (#27953)

This also fixes a bug where debug cargo test code actions would debug
all tests in a mod instead of a specific test

Release Notes:

- N/A
This commit is contained in:
Anthony Eid 2025-04-02 15:37:12 -04:00 committed by GitHub
parent 500964a6fa
commit 108ae0b5b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 42 additions and 17 deletions

View file

@ -471,7 +471,6 @@ impl DapStore {
initialize_args: config.initialize_args.clone(),
tcp_connection: config.tcp_connection.clone(),
locator: None,
args: Default::default(),
stop_on_entry: config.stop_on_entry,
};

View file

@ -29,7 +29,7 @@ impl DapLocator for CargoLocator {
};
let mut child = Command::new("cargo")
.args(&debug_config.args)
.args(&launch_config.args)
.arg("--message-format=json")
.current_dir(cwd)
.stdout(Stdio::piped())
@ -59,7 +59,30 @@ impl DapLocator for CargoLocator {
};
launch_config.program = executable;
debug_config.args.clear();
let mut test_name = None;
if launch_config
.args
.first()
.map_or(false, |arg| arg == "test")
{
if let Some(package_index) = launch_config
.args
.iter()
.position(|arg| arg == "-p" || arg == "--package")
{
test_name = launch_config
.args
.get(package_index + 2)
.filter(|name| !name.starts_with("--"))
.cloned();
}
}
launch_config.args.clear();
if let Some(test_name) = test_name {
launch_config.args.push(test_name);
}
Ok(())
}
}

View file

@ -225,6 +225,7 @@ impl LocalMode {
DebugRequestType::Launch(task::LaunchConfig {
program: "".to_owned(),
cwd: None,
args: Default::default(),
})
}
dap::StartDebuggingRequestArgumentsRequest::Attach => {