Restore theme sorting in Zed2 (#3563)

This PR restores the sorting of themes in the theme selector in Zed2.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers
2023-12-08 15:08:35 -05:00
committed by GitHub
parent 40b219f861
commit 4353bdb9d5
3 changed files with 37 additions and 15 deletions
+11 -2
View File
@@ -10,6 +10,12 @@ use crate::{
SystemColors, Theme, ThemeColors, ThemeFamily, ThemeStyles, UserTheme, UserThemeFamily,
};
#[derive(Debug, Clone)]
pub struct ThemeMeta {
pub name: SharedString,
pub appearance: Appearance,
}
pub struct ThemeRegistry {
themes: HashMap<SharedString, Arc<Theme>>,
}
@@ -94,8 +100,11 @@ impl ThemeRegistry {
self.themes.keys().cloned()
}
pub fn list(&self, _staff: bool) -> impl Iterator<Item = SharedString> + '_ {
self.themes.values().map(|theme| theme.name.clone())
pub fn list(&self, _staff: bool) -> impl Iterator<Item = ThemeMeta> + '_ {
self.themes.values().map(|theme| ThemeMeta {
name: theme.name.clone(),
appearance: theme.appearance(),
})
}
pub fn get(&self, name: &str) -> Result<Arc<Theme>> {
+9
View File
@@ -31,6 +31,15 @@ pub enum Appearance {
Dark,
}
impl Appearance {
pub fn is_light(&self) -> bool {
match self {
Self::Light => true,
Self::Dark => false,
}
}
}
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum LoadThemes {
/// Only load the base theme.