Reload themes defined in extensions (#7520)

This PR extends the extension directory watcher to also watch and reload
themes defined in extensions.

Release Notes:

- N/A

Co-authored-by: Max <max@zed.dev>
This commit is contained in:
Marshall Bowers 2024-02-07 16:11:24 -05:00 committed by GitHub
parent 31d9edfaaa
commit 2f4bb79553
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 71 additions and 16 deletions

View file

@ -33,6 +33,20 @@ pub struct ThemeSettings {
pub theme_overrides: Option<ThemeStyleContent>,
}
impl ThemeSettings {
pub fn reload_current_theme(cx: &mut AppContext) {
let mut theme_settings = ThemeSettings::get_global(cx).clone();
if let Some(theme_selection) = theme_settings.theme_selection.clone() {
let theme_name = theme_selection.theme(*SystemAppearance::global(cx));
if let Some(_theme) = theme_settings.switch_theme(&theme_name, cx) {
ThemeSettings::override_global(theme_settings, cx);
}
}
}
}
/// The appearance of the system.
#[derive(Debug, Clone, Copy, Deref)]
pub struct SystemAppearance(pub Appearance);