History

Introduce $ZED_CUSTOM_PYTHON_ACTIVE_ZED_TOOLCHAIN_RAW to work around (#31685)

Follow up to #31674 Release Notes: - N/A

Piotr Osiewicz committed 1 year ago

Commit 83135e91 parent 703ee292 files · +18 −7Browse files

Unified · Split

2 files
  1. crates/languages/src/python.rs +9 −5
  2. crates/project/src/debugger/locators/python.rs +9 −2
crates/languages/src/python.rs+9−5
@@ -357,6 +357,9 @@ const PYTHON_TEST_TARGET_TASK_VARIABLE: VariableName = · 356 unmodified lines
357const PYTHON_ACTIVE_TOOLCHAIN_PATH: VariableName =357const PYTHON_ACTIVE_TOOLCHAIN_PATH: VariableName =
358 VariableName::Custom(Cow::Borrowed("PYTHON_ACTIVE_ZED_TOOLCHAIN"));358 VariableName::Custom(Cow::Borrowed("PYTHON_ACTIVE_ZED_TOOLCHAIN"));
359 359
360const PYTHON_ACTIVE_TOOLCHAIN_PATH_RAW: VariableName =
361 VariableName::Custom(Cow::Borrowed("PYTHON_ACTIVE_ZED_TOOLCHAIN_RAW"));
362
360const PYTHON_MODULE_NAME_TASK_VARIABLE: VariableName =363const PYTHON_MODULE_NAME_TASK_VARIABLE: VariableName =
361 VariableName::Custom(Cow::Borrowed("PYTHON_MODULE_NAME"));364 VariableName::Custom(Cow::Borrowed("PYTHON_MODULE_NAME"));
362 365
@@ -378,24 +381,25 @@ impl ContextProvider for PythonContextProvider { · 15 unmodified lines
378 let worktree_id = location.buffer.read(cx).file().map(|f| f.worktree_id(cx));381 let worktree_id = location.buffer.read(cx).file().map(|f| f.worktree_id(cx));
379 382
380 cx.spawn(async move |cx| {383 cx.spawn(async move |cx| {
381 let active_toolchain = if let Some(worktree_id) = worktree_id {384 let raw_toolchain = if let Some(worktree_id) = worktree_id {
382 toolchains385 toolchains
383 .active_toolchain(worktree_id, Arc::from("".as_ref()), "Python".into(), cx)386 .active_toolchain(worktree_id, Arc::from("".as_ref()), "Python".into(), cx)
384 .await387 .await
385 .map_or_else(388 .map_or_else(
386 || "python3".to_owned(),389 || String::from("python3"),
387 |toolchain| format!("\"{}\"", toolchain.path),390 |toolchain| toolchain.path.to_string(),
388 )391 )
389 } else {392 } else {
390 String::from("python3")393 String::from("python3")
391 };394 };
395 let active_toolchain = format!("\"{raw_toolchain}\"");
392 let toolchain = (PYTHON_ACTIVE_TOOLCHAIN_PATH, active_toolchain);396 let toolchain = (PYTHON_ACTIVE_TOOLCHAIN_PATH, active_toolchain);
393 397 let raw_toolchain = (PYTHON_ACTIVE_TOOLCHAIN_PATH_RAW, raw_toolchain);
394 Ok(task::TaskVariables::from_iter(398 Ok(task::TaskVariables::from_iter(
395 test_target399 test_target
396 .into_iter()400 .into_iter()
397 .chain(module_target.into_iter())401 .chain(module_target.into_iter())
398 .chain([toolchain]),402 .chain([toolchain, raw_toolchain]),
399 ))403 ))
400 })404 })
401 }405 }
crates/project/src/debugger/locators/python.rs+9−2
@@ -5,7 +5,7 @@ use async_trait::async_trait; · 4 unmodified lines
5use dap::{DapLocator, DebugRequest, adapters::DebugAdapterName};5use dap::{DapLocator, DebugRequest, adapters::DebugAdapterName};
6use gpui::SharedString;6use gpui::SharedString;
7 7
8use task::{DebugScenario, SpawnInTerminal, TaskTemplate};8use task::{DebugScenario, SpawnInTerminal, TaskTemplate, VariableName};
9 9
10pub(crate) struct PythonLocator;10pub(crate) struct PythonLocator;
11 11
@@ -35,6 +35,13 @@ impl DapLocator for PythonLocator { · 23 unmodified lines
35 // We cannot debug selections.35 // We cannot debug selections.
36 return None;36 return None;
37 }37 }
38 let command = if build_config.command
39 == VariableName::Custom("PYTHON_ACTIVE_ZED_TOOLCHAIN".into()).template_value()
40 {
41 VariableName::Custom("PYTHON_ACTIVE_ZED_TOOLCHAIN_RAW".into()).template_value()
42 } else {
43 build_config.command.clone()
44 };
38 let module_specifier_position = build_config45 let module_specifier_position = build_config
39 .args46 .args
40 .iter()47 .iter()
@@ -68,7 +75,7 @@ impl DapLocator for PythonLocator { · 27 unmodified lines
68 }75 }
69 let mut config = serde_json::json!({76 let mut config = serde_json::json!({
70 "request": "launch",77 "request": "launch",
71 "python": build_config.command,78 "python": command,
72 "args": args,79 "args": args,
73 "cwd": build_config.cwd.clone()80 "cwd": build_config.cwd.clone()
74 });81 });