theme: Warn when deprecated `scrollbar_thumb.background` style is used (#13081)

Marshall Bowers created

This PR adds a warning when the deprecated `scrollbar_thumb.background`
style property is present in a theme.

This property has been succeeded by `scrollbar.thumb.background`.

The primary reason for this is to get it into the `zed-extension` CLI so
that we can use it to detect which themes need to be updated.

Release Notes:

- N/A

Change summary

Cargo.lock                   |  1 +
crates/theme/Cargo.toml      |  1 +
crates/theme/src/registry.rs | 18 ++++++++++++++++--
crates/theme/src/schema.rs   | 19 ++++++++++++++-----
4 files changed, 32 insertions(+), 7 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -10527,6 +10527,7 @@ dependencies = [
  "futures 0.3.28",
  "gpui",
  "indexmap 1.9.3",
+ "log",
  "palette",
  "parking_lot",
  "refineable",

crates/theme/Cargo.toml 🔗

@@ -25,6 +25,7 @@ fs.workspace = true
 futures.workspace = true
 gpui.workspace = true
 indexmap.workspace = true
+log.workspace = true
 palette = { workspace = true, default-features = false, features = ["std"] }
 parking_lot.workspace = true
 refineable.workspace = true

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.

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()