languages: Fix python tasks failing when binary contains whitespaces (#37454)

Fixes https://github.com/zed-industries/zed/issues/33459

Release Notes:

- Fixed python tasks failing when the python binary path contains
whitespaces
This commit is contained in:
Lukas Wirth
2025-09-03 16:11:36 +02:00
committed by GitHub
parent ebc22c290b
commit d80f9dda75
2 changed files with 21 additions and 34 deletions
+4 -12
View File
@@ -25,7 +25,7 @@ impl DapLocator for PythonLocator {
if adapter.0.as_ref() != "Debugpy" {
return None;
}
let valid_program = build_config.command.starts_with("$ZED_")
let valid_program = build_config.command.starts_with("\"$ZED_")
|| Path::new(&build_config.command)
.file_name()
.is_some_and(|name| name.to_str().is_some_and(|path| path.starts_with("python")));
@@ -33,13 +33,7 @@ impl DapLocator for PythonLocator {
// We cannot debug selections.
return None;
}
let command = if build_config.command
== VariableName::Custom("PYTHON_ACTIVE_ZED_TOOLCHAIN".into()).template_value()
{
VariableName::Custom("PYTHON_ACTIVE_ZED_TOOLCHAIN_RAW".into()).template_value()
} else {
build_config.command.clone()
};
let command = build_config.command.clone();
let module_specifier_position = build_config
.args
.iter()
@@ -57,10 +51,8 @@ impl DapLocator for PythonLocator {
let program_position = mod_name
.is_none()
.then(|| {
build_config
.args
.iter()
.position(|arg| *arg == "\"$ZED_FILE\"")
let zed_file = VariableName::File.template_value_with_whitespace();
build_config.args.iter().position(|arg| *arg == zed_file)
})
.flatten();
let args = if let Some(position) = program_position {