Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
theme: Warn when deprecated `scrollbar_thumb.background` style is used (#13081)
Marshall Bowers064bdab459b2
diff --git a/Cargo.lock b/Cargo.lockindex 8da51b2dad5..2dba6b34b29 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -10527,6 +10527,7 @@ dependencies = ["futures 0.3.28","gpui","indexmap 1.9.3",+ "log","palette","parking_lot","refineable",diff --git a/crates/theme/Cargo.toml b/crates/theme/Cargo.tomlindex eaf738439bb..934faa11862 100644--- a/crates/theme/Cargo.toml+++ b/crates/theme/Cargo.toml@@ -25,6 +25,7 @@ fs.workspace = truefutures.workspace = truegpui.workspace = trueindexmap.workspace = true+log.workspace = truepalette = { workspace = true, default-features = false, features = ["std"] }parking_lot.workspace = truerefineable.workspace = truediff --git a/crates/theme/src/registry.rs b/crates/theme/src/registry.rsindex 6e13df6045d..b70377f4408 100644--- a/crates/theme/src/registry.rs+++ b/crates/theme/src/registry.rs@@ -263,9 +263,23 @@ impl ThemeRegistry {pub async fn read_user_theme(theme_path: &Path, fs: Arc<dyn Fs>) -> Result<ThemeFamilyContent> {let reader = fs.open_sync(theme_path).await?;- let theme = serde_json_lenient::from_reader(reader)?;+ let theme_family: ThemeFamilyContent = serde_json_lenient::from_reader(reader)?;- Ok(theme)+ for theme in &theme_family.themes {+ if theme+ .style+ .colors+ .deprecated_scrollbar_thumb_background+ .is_some()+ {+ log::warn!(+ r#"Theme "{theme_name}" is using a deprecated style property: scrollbar_thumb.background. Use `scrollbar.thumb.background` instead."#,+ theme_name = theme.name+ )+ }+ }++ Ok(theme_family)}/// Loads the user theme from the specified path and adds it to the registry.diff --git a/crates/theme/src/schema.rs b/crates/theme/src/schema.rsindex e79b80ff44e..81a80d3f5b7 100644--- a/crates/theme/src/schema.rs+++ b/crates/theme/src/schema.rs@@ -327,11 +327,15 @@ pub struct ThemeColorsContent {#[serde(rename = "pane_group.border")]pub pane_group_border: Option<String>,+ /// The deprecated version of `scrollbar.thumb.background`.+ ///+ /// Don't use this field.+ #[serde(rename = "scrollbar_thumb.background", skip_serializing)]+ #[schemars(skip)]+ pub deprecated_scrollbar_thumb_background: Option<String>,+/// The color of the scrollbar thumb.- #[serde(- rename = "scrollbar.thumb.background",- alias = "scrollbar_thumb.background"- )]+ #[serde(rename = "scrollbar.thumb.background")]pub scrollbar_thumb_background: Option<String>,/// The color of the scrollbar thumb when hovered over.@@ -699,7 +703,12 @@ impl ThemeColorsContent {scrollbar_thumb_background: self.scrollbar_thumb_background.as_ref()- .and_then(|color| try_parse_color(color).ok()),+ .and_then(|color| try_parse_color(color).ok())+ .or_else(|| {+ self.deprecated_scrollbar_thumb_background+ .as_ref()+ .and_then(|color| try_parse_color(color).ok())+ }),scrollbar_thumb_hover_background: self.scrollbar_thumb_hover_background.as_ref()