From 999db0a4bd2eed7cbc75624a0599c7c45624969f Mon Sep 17 00:00:00 2001 From: Lionel DARNIS Date: Tue, 5 May 2026 19:07:35 +0200 Subject: [PATCH] =?UTF-8?q?yoda:=20cosmic-theme=20cleanup=20(4=E2=86=920?= =?UTF-8?q?=20warnings)=20=E2=80=94=20workspace=20at=200=20warnings=20tota?= =?UTF-8?q?l?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit theme::Builder::build: - #[allow(unused_assignments)] with a note explaining the pattern: the component_hovered/pressed_overlay seeds at the top of the function are overwritten by every container block (primary, secondary, …) before being read, which is what unused_assignments flagged. vs_code.rs: - Add doc + # Errors section to Theme::apply_vs_code and the associated Theme::reset_vs_code (was missing under #![warn(missing_docs)]). Cargo.toml profile move: - cosmic-theme had a [profile.dev.package] block that Cargo silently ignores in non-root manifests. Move the insta/similar opt-level=3 hint to the workspace root and drop the dead block from the cosmic-theme manifest. Removes the cargo-level "profiles for the non root package will be ignored" notice that came up on every check. Leyoda 2026 – GPLv3 --- Cargo.toml | 8 ++++++++ cosmic-theme/Cargo.toml | 3 --- cosmic-theme/src/model/theme.rs | 6 ++++++ cosmic-theme/src/output/vs_code.rs | 15 +++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) 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)?;