From 3ae3e1fce8134e00599e88e81a5acede5f8773f2 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 9 Dec 2025 14:55:44 -0500 Subject: [PATCH] Don't use a heuristic for icon path --- crates/ui/src/components/icon.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/crates/ui/src/components/icon.rs b/crates/ui/src/components/icon.rs index 1c8e36ec18d6184b38eb6772e8f5a13be181ae00..b587d3866f06f426db89c8cc60bebe8907cf51d9 100644 --- a/crates/ui/src/components/icon.rs +++ b/crates/ui/src/components/icon.rs @@ -126,17 +126,6 @@ enum IconSource { ExternalSvg(SharedString), } -impl IconSource { - fn from_path(path: impl Into) -> Self { - let path = path.into(); - if path.starts_with("icons/") { - Self::Embedded(path) - } else { - Self::External(Arc::from(PathBuf::from(path.as_ref()))) - } - } -} - #[derive(IntoElement, RegisterComponent)] pub struct Icon { source: IconSource, @@ -155,9 +144,23 @@ impl Icon { } } + /// Create an icon from an embedded SVG path (e.g., "icons/ai.svg"). + /// These are SVGs bundled in the Zed binary. + pub fn from_embedded(path: impl Into) -> Self { + Self { + source: IconSource::Embedded(path.into()), + color: Color::default(), + size: IconSize::default().rems(), + transformation: Transformation::default(), + } + } + + /// Create an icon from an external file path (e.g., from an extension). + /// This renders the file as a raster image. pub fn from_path(path: impl Into) -> Self { + let path = path.into(); Self { - source: IconSource::from_path(path), + source: IconSource::External(Arc::from(PathBuf::from(path.as_ref()))), color: Color::default(), size: IconSize::default().rems(), transformation: Transformation::default(),