From b4a8084350604340b2b1b4888b64a82bb788ba5c Mon Sep 17 00:00:00 2001 From: Jan-Bulthuis Date: Sun, 19 Jul 2026 19:41:40 +0200 Subject: [PATCH] feat: compute scope intersection for theme pair --- src/themes.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/themes.rs b/src/themes.rs index 1baee4c..7fcf903 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -1,5 +1,5 @@ use std::{ - collections::{HashMap, HashSet}, + collections::{BTreeSet, HashMap, HashSet}, error::Error, fs, path::Path, @@ -218,6 +218,21 @@ pub fn init(config: &AppConfig) { } } +/// The intersection of scopes between two themes. +pub fn shared_scopes(light: &str, dark: &str) -> Option> { + let registry = REGISTRY.get()?; + let light = registry.themes.get(light)?; + let dark = registry.themes.get(dark)?; + Some( + light + .styles + .keys() + .filter(|k| dark.styles.contains_key(*k)) + .cloned() + .collect(), + ) +} + pub fn theme_css_func() -> Func { theme_css::func() }