diff --git a/Cargo.toml b/Cargo.toml index 2f38df6..85847c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -264,5 +264,13 @@ exclude = ["iced", "examples"] [workspace.dependencies] dirs = "6.0.0" +# Speed up snapshot diffing in cosmic-theme tests. Cargo silently ignores +# [profile.*] blocks in non-root manifests, so this lives at the +# workspace root. +[profile.dev.package.insta] +opt-level = 3 +[profile.dev.package.similar] +opt-level = 3 + [dev-dependencies] tempfile = "3.27.0" diff --git a/cosmic-theme/Cargo.toml b/cosmic-theme/Cargo.toml index 7e408d8..9ee641e 100644 --- a/cosmic-theme/Cargo.toml +++ b/cosmic-theme/Cargo.toml @@ -34,6 +34,3 @@ thiserror = "2.0.18" [dev-dependencies] insta = "1.47.2" -[profile.dev.package] -insta.opt-level = 3 -similar.opt-level = 3 diff --git a/cosmic-theme/src/model/theme.rs b/cosmic-theme/src/model/theme.rs index 5db0f32..36480f9 100644 --- a/cosmic-theme/src/model/theme.rs +++ b/cosmic-theme/src/model/theme.rs @@ -953,6 +953,12 @@ impl ThemeBuilder { } #[allow(clippy::too_many_lines)] + // The component_hovered/pressed_overlay vars are seeded once near the + // top of this fn and then reassigned inside each container block + // (primary, secondary, …) before being read again. The initial seed + // is therefore overwritten before any read, which is what the + // unused_assignments lint flags below. + #[allow(unused_assignments)] /// build the theme pub fn build(self) -> Theme { let Self { diff --git a/cosmic-theme/src/output/vs_code.rs b/cosmic-theme/src/output/vs_code.rs index 43c36bb..f49c888 100644 --- a/cosmic-theme/src/output/vs_code.rs +++ b/cosmic-theme/src/output/vs_code.rs @@ -266,6 +266,14 @@ impl From for VsTheme { } impl Theme { + /// Write this theme to VS Code's `settings.json` as a + /// `workbench.colorCustomizations` entry, and enable + /// `window.autoDetectColorScheme` so VS Code follows the system theme. + /// + /// # Errors + /// + /// Returns an `OutputError` if the user config dir is missing, the + /// settings file cannot be read/written, or its JSON is invalid. #[cold] pub fn apply_vs_code(self) -> Result<(), OutputError> { let vs_theme = VsTheme::from(self); @@ -291,6 +299,13 @@ impl Theme { Ok(()) } + /// Remove the `workbench.colorCustomizations` entry previously written + /// by [`Theme::apply_vs_code`] from VS Code's `settings.json`. + /// + /// # Errors + /// + /// Returns an `OutputError` if the user config dir is missing, the + /// settings file cannot be read/written, or its JSON is invalid. #[cold] pub fn reset_vs_code() -> Result<(), OutputError> { let mut config_dir = dirs::config_dir().ok_or(OutputError::MissingConfigDir)?;