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:
@@ -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>> {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user