From 20635efb083cfed0a264bf88f8d4d7742af9642d Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 16 Oct 2025 16:09:57 -0700 Subject: [PATCH 1/4] Make python adapter error message better --- crates/dap_adapters/src/python.rs | 15 ++-- crates/gpui/examples/focus_visible.rs | 110 ++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 6 deletions(-) create mode 100644 crates/gpui/examples/focus_visible.rs diff --git a/crates/dap_adapters/src/python.rs b/crates/dap_adapters/src/python.rs index db9d66a31d895f..46d8890db6809b 100644 --- a/crates/dap_adapters/src/python.rs +++ b/crates/dap_adapters/src/python.rs @@ -239,20 +239,23 @@ impl PythonDebugAdapter { })? }; - let did_succeed = util::command::new_smol_command(base_python) + // 1. Does this and directory exist (the current working directory here) + // 2. If it does, what's the output of the command + let output = util::command::new_smol_command(base_python) .args(["-m", "venv", "zed_base_venv"]) .current_dir( paths::debug_adapters_dir().join(Self::DEBUG_ADAPTER_NAME.as_ref()), ) .spawn() .map_err(|e| format!("{e:#?}"))? - .status() + .output() .await - .map_err(|e| format!("{e:#?}"))? - .success(); + .map_err(|e| format!("{e:#?}"))?; - if !did_succeed { - return Err("Failed to create base virtual environment".into()); + if !output.status.success() { + let stderr = String::from_utf8_lossy(&output.stderr); + let stdout = String::from_utf8_lossy(&output.stdout); + return Err(format!("Failed to create base virtual environment:\nstderr: {stderr}\nstdout: {stdout}\n")); } const PYTHON_PATH: &str = if cfg!(target_os = "windows") { diff --git a/crates/gpui/examples/focus_visible.rs b/crates/gpui/examples/focus_visible.rs new file mode 100644 index 00000000000000..fe47c8dc1982b2 --- /dev/null +++ b/crates/gpui/examples/focus_visible.rs @@ -0,0 +1,110 @@ +use gpui::{ + App, Application, Bounds, Context, SharedString, Window, WindowBounds, WindowOptions, actions, + div, prelude::*, px, rgb, size, +}; + +struct HelloWorld {} + +impl Render for HelloWorld { + fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { + div() + .flex() + .flex_col() + .gap_3() + .bg(rgb(0x505050)) + .size(px(500.0)) + .justify_center() + .items_center() + .shadow_lg() + .border_1() + .border_color(rgb(0x0000ff)) + .text_xl() + .text_color(rgb(0xffffff)) + .child("Tabbing through these items should show a focus ring, but clicking on them shouldn't") + .child( + div() + .flex() + .gap_2() + .child( + div() + .size_8() + .bg(gpui::red()) + .tab_index(0) + .border_1() + .border_dashed() + .rounded_md() + .border_color(gpui::white()), + ) + .child( + div() + .size_8() + .bg(gpui::green()) + .tab_index(0) + .border_1() + .border_dashed() + .rounded_md() + .border_color(gpui::white()), + ) + .child( + div() + .size_8() + .bg(gpui::blue()) + .tab_index(0) + .border_1() + .border_dashed() + .rounded_md() + .border_color(gpui::white()), + ) + .child( + div() + .size_8() + .bg(gpui::yellow()) + .tab_index(0) + .border_1() + .border_dashed() + .rounded_md() + .border_color(gpui::white()), + ) + .child( + div() + .size_8() + .bg(gpui::black()) + .tab_index(0) + .border_1() + .border_dashed() + .rounded_md() + .rounded_md() + .border_color(gpui::white()), + ) + .child( + div() + .size_8() + .bg(gpui::white()) + .tab_index(0) + .border_1() + .border_dashed() + .rounded_md() + .border_color(gpui::black()), + ), + ) + } +} + +actions!(example, [Tab]); + +fn main() { + Application::new().run(|cx: &mut App| { + cx.bind_keys([gpui::KeyBinding::new("tab")]); + + let bounds = Bounds::centered(None, size(px(500.), px(500.0)), cx); + cx.open_window( + WindowOptions { + window_bounds: Some(WindowBounds::Windowed(bounds)), + ..Default::default() + }, + |_, cx| cx.new(|_| HelloWorld {}), + ) + .unwrap(); + cx.activate(true); + }); +} From f80f5c976242d269027dfe15617e3b39c918b41e Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 16 Oct 2025 16:10:47 -0700 Subject: [PATCH 2/4] Whoops --- crates/dap_adapters/src/python.rs | 2 - crates/gpui/examples/focus_visible.rs | 110 -------------------------- 2 files changed, 112 deletions(-) delete mode 100644 crates/gpui/examples/focus_visible.rs diff --git a/crates/dap_adapters/src/python.rs b/crates/dap_adapters/src/python.rs index 46d8890db6809b..ebc4d7412267ec 100644 --- a/crates/dap_adapters/src/python.rs +++ b/crates/dap_adapters/src/python.rs @@ -239,8 +239,6 @@ impl PythonDebugAdapter { })? }; - // 1. Does this and directory exist (the current working directory here) - // 2. If it does, what's the output of the command let output = util::command::new_smol_command(base_python) .args(["-m", "venv", "zed_base_venv"]) .current_dir( diff --git a/crates/gpui/examples/focus_visible.rs b/crates/gpui/examples/focus_visible.rs deleted file mode 100644 index fe47c8dc1982b2..00000000000000 --- a/crates/gpui/examples/focus_visible.rs +++ /dev/null @@ -1,110 +0,0 @@ -use gpui::{ - App, Application, Bounds, Context, SharedString, Window, WindowBounds, WindowOptions, actions, - div, prelude::*, px, rgb, size, -}; - -struct HelloWorld {} - -impl Render for HelloWorld { - fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { - div() - .flex() - .flex_col() - .gap_3() - .bg(rgb(0x505050)) - .size(px(500.0)) - .justify_center() - .items_center() - .shadow_lg() - .border_1() - .border_color(rgb(0x0000ff)) - .text_xl() - .text_color(rgb(0xffffff)) - .child("Tabbing through these items should show a focus ring, but clicking on them shouldn't") - .child( - div() - .flex() - .gap_2() - .child( - div() - .size_8() - .bg(gpui::red()) - .tab_index(0) - .border_1() - .border_dashed() - .rounded_md() - .border_color(gpui::white()), - ) - .child( - div() - .size_8() - .bg(gpui::green()) - .tab_index(0) - .border_1() - .border_dashed() - .rounded_md() - .border_color(gpui::white()), - ) - .child( - div() - .size_8() - .bg(gpui::blue()) - .tab_index(0) - .border_1() - .border_dashed() - .rounded_md() - .border_color(gpui::white()), - ) - .child( - div() - .size_8() - .bg(gpui::yellow()) - .tab_index(0) - .border_1() - .border_dashed() - .rounded_md() - .border_color(gpui::white()), - ) - .child( - div() - .size_8() - .bg(gpui::black()) - .tab_index(0) - .border_1() - .border_dashed() - .rounded_md() - .rounded_md() - .border_color(gpui::white()), - ) - .child( - div() - .size_8() - .bg(gpui::white()) - .tab_index(0) - .border_1() - .border_dashed() - .rounded_md() - .border_color(gpui::black()), - ), - ) - } -} - -actions!(example, [Tab]); - -fn main() { - Application::new().run(|cx: &mut App| { - cx.bind_keys([gpui::KeyBinding::new("tab")]); - - let bounds = Bounds::centered(None, size(px(500.), px(500.0)), cx); - cx.open_window( - WindowOptions { - window_bounds: Some(WindowBounds::Windowed(bounds)), - ..Default::default() - }, - |_, cx| cx.new(|_| HelloWorld {}), - ) - .unwrap(); - cx.activate(true); - }); -} From f2c1a9735738d6b6d35604df5f33c1d8c9bf454b Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 16 Oct 2025 16:13:30 -0700 Subject: [PATCH 3/4] even betterer --- crates/dap_adapters/src/python.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/dap_adapters/src/python.rs b/crates/dap_adapters/src/python.rs index ebc4d7412267ec..75e29ad64aab6c 100644 --- a/crates/dap_adapters/src/python.rs +++ b/crates/dap_adapters/src/python.rs @@ -239,10 +239,11 @@ impl PythonDebugAdapter { })? }; + let debug_adapter_path = paths::debug_adapters_dir().join(Self::DEBUG_ADAPTER_NAME.as_ref()); let output = util::command::new_smol_command(base_python) .args(["-m", "venv", "zed_base_venv"]) .current_dir( - paths::debug_adapters_dir().join(Self::DEBUG_ADAPTER_NAME.as_ref()), + debug_adapter_path, ) .spawn() .map_err(|e| format!("{e:#?}"))? @@ -253,7 +254,8 @@ impl PythonDebugAdapter { if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); let stdout = String::from_utf8_lossy(&output.stdout); - return Err(format!("Failed to create base virtual environment:\nstderr: {stderr}\nstdout: {stdout}\n")); + let debug_adapter_path = debug_adapter_path.display(); + return Err(format!("Failed to create base virtual environment in:\n{debug_adapter_path_str}\nstderr:\n{stderr}\nstdout:\n{stdout}\n")); } const PYTHON_PATH: &str = if cfg!(target_os = "windows") { From 4e216290c98041cbc2f14cd05193659475f1ce8e Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Thu, 16 Oct 2025 16:20:17 -0700 Subject: [PATCH 4/4] bettererer --- crates/dap_adapters/src/python.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/dap_adapters/src/python.rs b/crates/dap_adapters/src/python.rs index 75e29ad64aab6c..1efe326f4380bb 100644 --- a/crates/dap_adapters/src/python.rs +++ b/crates/dap_adapters/src/python.rs @@ -240,10 +240,10 @@ impl PythonDebugAdapter { }; let debug_adapter_path = paths::debug_adapters_dir().join(Self::DEBUG_ADAPTER_NAME.as_ref()); - let output = util::command::new_smol_command(base_python) + let output = util::command::new_smol_command(&base_python) .args(["-m", "venv", "zed_base_venv"]) .current_dir( - debug_adapter_path, + &debug_adapter_path, ) .spawn() .map_err(|e| format!("{e:#?}"))? @@ -255,7 +255,7 @@ impl PythonDebugAdapter { let stderr = String::from_utf8_lossy(&output.stderr); let stdout = String::from_utf8_lossy(&output.stdout); let debug_adapter_path = debug_adapter_path.display(); - return Err(format!("Failed to create base virtual environment in:\n{debug_adapter_path_str}\nstderr:\n{stderr}\nstdout:\n{stdout}\n")); + return Err(format!("Failed to create base virtual environment with {base_python} in:\n{debug_adapter_path}\nstderr:\n{stderr}\nstdout:\n{stdout}\n")); } const PYTHON_PATH: &str = if cfg!(target_os = "windows") {