theme: Warn when deprecated scrollbar_thumb.background style is used (#13081)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run

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
This commit is contained in:
Marshall Bowers 2024-06-15 22:14:39 -04:00 committed by GitHub
parent 38cb95f427
commit 064bdab459
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 7 deletions

1
Cargo.lock generated
View file

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

View file

@ -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

View file

@ -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.

View file

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