Introduce $ZED_CUSTOM_PYTHON_ACTIVE_ZED_TOOLCHAIN_RAW to work around (#31685)
Follow up to #31674 Release Notes: - N/A Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
parent
703ee29658
commit
83135e98e6
2 changed files with 18 additions and 7 deletions
|
@ -357,6 +357,9 @@ const PYTHON_TEST_TARGET_TASK_VARIABLE: VariableName =
|
||||||
const PYTHON_ACTIVE_TOOLCHAIN_PATH: VariableName =
|
const PYTHON_ACTIVE_TOOLCHAIN_PATH: VariableName =
|
||||||
VariableName::Custom(Cow::Borrowed("PYTHON_ACTIVE_ZED_TOOLCHAIN"));
|
VariableName::Custom(Cow::Borrowed("PYTHON_ACTIVE_ZED_TOOLCHAIN"));
|
||||||
|
|
||||||
|
const PYTHON_ACTIVE_TOOLCHAIN_PATH_RAW: VariableName =
|
||||||
|
VariableName::Custom(Cow::Borrowed("PYTHON_ACTIVE_ZED_TOOLCHAIN_RAW"));
|
||||||
|
|
||||||
const PYTHON_MODULE_NAME_TASK_VARIABLE: VariableName =
|
const PYTHON_MODULE_NAME_TASK_VARIABLE: VariableName =
|
||||||
VariableName::Custom(Cow::Borrowed("PYTHON_MODULE_NAME"));
|
VariableName::Custom(Cow::Borrowed("PYTHON_MODULE_NAME"));
|
||||||
|
|
||||||
|
@ -378,24 +381,25 @@ impl ContextProvider for PythonContextProvider {
|
||||||
let worktree_id = location.buffer.read(cx).file().map(|f| f.worktree_id(cx));
|
let worktree_id = location.buffer.read(cx).file().map(|f| f.worktree_id(cx));
|
||||||
|
|
||||||
cx.spawn(async move |cx| {
|
cx.spawn(async move |cx| {
|
||||||
let active_toolchain = if let Some(worktree_id) = worktree_id {
|
let raw_toolchain = if let Some(worktree_id) = worktree_id {
|
||||||
toolchains
|
toolchains
|
||||||
.active_toolchain(worktree_id, Arc::from("".as_ref()), "Python".into(), cx)
|
.active_toolchain(worktree_id, Arc::from("".as_ref()), "Python".into(), cx)
|
||||||
.await
|
.await
|
||||||
.map_or_else(
|
.map_or_else(
|
||||||
|| "python3".to_owned(),
|
|| String::from("python3"),
|
||||||
|toolchain| format!("\"{}\"", toolchain.path),
|
|toolchain| toolchain.path.to_string(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
String::from("python3")
|
String::from("python3")
|
||||||
};
|
};
|
||||||
|
let active_toolchain = format!("\"{raw_toolchain}\"");
|
||||||
let toolchain = (PYTHON_ACTIVE_TOOLCHAIN_PATH, active_toolchain);
|
let toolchain = (PYTHON_ACTIVE_TOOLCHAIN_PATH, active_toolchain);
|
||||||
|
let raw_toolchain = (PYTHON_ACTIVE_TOOLCHAIN_PATH_RAW, raw_toolchain);
|
||||||
Ok(task::TaskVariables::from_iter(
|
Ok(task::TaskVariables::from_iter(
|
||||||
test_target
|
test_target
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(module_target.into_iter())
|
.chain(module_target.into_iter())
|
||||||
.chain([toolchain]),
|
.chain([toolchain, raw_toolchain]),
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use async_trait::async_trait;
|
||||||
use dap::{DapLocator, DebugRequest, adapters::DebugAdapterName};
|
use dap::{DapLocator, DebugRequest, adapters::DebugAdapterName};
|
||||||
use gpui::SharedString;
|
use gpui::SharedString;
|
||||||
|
|
||||||
use task::{DebugScenario, SpawnInTerminal, TaskTemplate};
|
use task::{DebugScenario, SpawnInTerminal, TaskTemplate, VariableName};
|
||||||
|
|
||||||
pub(crate) struct PythonLocator;
|
pub(crate) struct PythonLocator;
|
||||||
|
|
||||||
|
@ -35,6 +35,13 @@ impl DapLocator for PythonLocator {
|
||||||
// We cannot debug selections.
|
// We cannot debug selections.
|
||||||
return None;
|
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 module_specifier_position = build_config
|
let module_specifier_position = build_config
|
||||||
.args
|
.args
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -68,7 +75,7 @@ impl DapLocator for PythonLocator {
|
||||||
}
|
}
|
||||||
let mut config = serde_json::json!({
|
let mut config = serde_json::json!({
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"python": build_config.command,
|
"python": command,
|
||||||
"args": args,
|
"args": args,
|
||||||
"cwd": build_config.cwd.clone()
|
"cwd": build_config.cwd.clone()
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue