Correctly reload theme on :config-reload

The current implementation didn't reload the theme if no no theme was
explicitly configured (so the default theme was used). This commit
brings `refresh_theme` in line with the initialization code.
pull/6476/head^2
Pascal Kuthe 2 years ago committed by Blaž Hrastnik
parent 67783ddfd4
commit ab819d80f1
No known key found for this signature in database
GPG Key ID: 1238B9C4AD889640

@ -393,20 +393,23 @@ impl Application {
/// Refresh theme after config change /// Refresh theme after config change
fn refresh_theme(&mut self, config: &Config) -> Result<(), Error> { fn refresh_theme(&mut self, config: &Config) -> Result<(), Error> {
if let Some(theme) = config.theme.clone() { let true_color = config.editor.true_color || crate::true_color();
let true_color = self.true_color(); let theme = config
let theme = self .theme
.theme_loader .as_ref()
.load(&theme) .and_then(|theme| {
.map_err(|err| anyhow::anyhow!("Failed to load theme `{}`: {}", theme, err))?; self.theme_loader
.load(theme)
if true_color || theme.is_16_color() { .map_err(|e| {
self.editor.set_theme(theme); log::warn!("failed to load theme `{}` - {}", theme, e);
} else { e
anyhow::bail!("theme requires truecolor support, which is not available") })
} .ok()
} .filter(|theme| (true_color || theme.is_16_color()))
})
.unwrap_or_else(|| self.theme_loader.default_theme(true_color));
self.editor.set_theme(theme);
Ok(()) Ok(())
} }
@ -431,10 +434,6 @@ impl Application {
} }
} }
fn true_color(&self) -> bool {
self.config.load().editor.true_color || crate::true_color()
}
#[cfg(windows)] #[cfg(windows)]
// no signal handling available on windows // no signal handling available on windows
pub async fn handle_signals(&mut self, _signal: ()) {} pub async fn handle_signals(&mut self, _signal: ()) {}

Loading…
Cancel
Save