Detailed changes
@@ -96,6 +96,8 @@ impl ExtensionHostProxy {
}
pub trait ExtensionThemeProxy: Send + Sync + 'static {
+ fn set_extensions_loaded(&self);
+
fn list_theme_names(&self, theme_path: PathBuf, fs: Arc<dyn Fs>) -> Task<Result<Vec<String>>>;
fn remove_user_themes(&self, themes: Vec<SharedString>);
@@ -123,6 +125,14 @@ pub trait ExtensionThemeProxy: Send + Sync + 'static {
}
impl ExtensionThemeProxy for ExtensionHostProxy {
+ fn set_extensions_loaded(&self) {
+ let Some(proxy) = self.theme_proxy.read().clone() else {
+ return;
+ };
+
+ proxy.set_extensions_loaded()
+ }
+
fn list_theme_names(&self, theme_path: PathBuf, fs: Arc<dyn Fs>) -> Task<Result<Vec<String>>> {
let Some(proxy) = self.theme_proxy.read().clone() else {
return Task::ready(Ok(Vec::new()));
@@ -1290,6 +1290,7 @@ impl ExtensionStore {
}
this.wasm_extensions.extend(wasm_extensions);
+ this.proxy.set_extensions_loaded();
this.proxy.reload_current_theme(cx);
this.proxy.reload_current_icon_theme(cx);
})
@@ -50,6 +50,8 @@ impl Global for GlobalThemeRegistry {}
struct ThemeRegistryState {
themes: HashMap<SharedString, Arc<Theme>>,
icon_themes: HashMap<SharedString, Arc<IconTheme>>,
+ /// Whether the extensions have been loaded yet.
+ extensions_loaded: bool,
}
/// The registry for themes.
@@ -82,6 +84,7 @@ impl ThemeRegistry {
state: RwLock::new(ThemeRegistryState {
themes: HashMap::default(),
icon_themes: HashMap::default(),
+ extensions_loaded: false,
}),
assets,
};
@@ -100,6 +103,16 @@ impl ThemeRegistry {
registry
}
+ /// Returns whether the extensions have been loaded.
+ pub fn extensions_loaded(&self) -> bool {
+ self.state.read().extensions_loaded
+ }
+
+ /// Sets the flag indicating that the extensions have loaded.
+ pub fn set_extensions_loaded(&self) {
+ self.state.write().extensions_loaded = true;
+ }
+
fn insert_theme_families(&self, families: impl IntoIterator<Item = ThemeFamily>) {
for family in families.into_iter() {
self.insert_themes(family.themes);
@@ -157,7 +157,11 @@ impl ThemeSettings {
// If the selected theme doesn't exist, fall back to a default theme
// based on the system appearance.
let theme_registry = ThemeRegistry::global(cx);
- if theme_registry.get(theme_name).ok().is_none() {
+ if let Err(err @ ThemeNotFoundError(_)) = theme_registry.get(theme_name) {
+ if theme_registry.extensions_loaded() {
+ log::error!("{err}");
+ }
+
theme_name = Self::default_theme(*system_appearance);
};
@@ -180,11 +184,13 @@ impl ThemeSettings {
// If the selected icon theme doesn't exist, fall back to the default theme.
let theme_registry = ThemeRegistry::global(cx);
- if theme_registry
- .get_icon_theme(icon_theme_name)
- .ok()
- .is_none()
+ if let Err(err @ IconThemeNotFoundError(_)) =
+ theme_registry.get_icon_theme(icon_theme_name)
{
+ if theme_registry.extensions_loaded() {
+ log::error!("{err}");
+ }
+
icon_theme_name = DEFAULT_ICON_THEME_NAME;
};
@@ -848,7 +854,9 @@ impl settings::Settings for ThemeSettings {
this.active_theme = theme;
}
Err(err @ ThemeNotFoundError(_)) => {
- log::error!("{err}");
+ if themes.extensions_loaded() {
+ log::error!("{err}");
+ }
}
}
}
@@ -866,7 +874,9 @@ impl settings::Settings for ThemeSettings {
this.active_icon_theme = icon_theme;
}
Err(err @ IconThemeNotFoundError(_)) => {
- log::error!("{err}");
+ if themes.extensions_loaded() {
+ log::error!("{err}");
+ }
}
}
}
@@ -24,6 +24,10 @@ struct ThemeRegistryProxy {
}
impl ExtensionThemeProxy for ThemeRegistryProxy {
+ fn set_extensions_loaded(&self) {
+ self.theme_registry.set_extensions_loaded();
+ }
+
fn list_theme_names(&self, theme_path: PathBuf, fs: Arc<dyn Fs>) -> Task<Result<Vec<String>>> {
self.executor.spawn(async move {
let themes = theme::read_user_theme(&theme_path, fs).await?;