on master help sign in
Correctly reload theme on :config-reload
ab819d8Pascal Kuthe
helix-term/src/application.rs+16−17
@@ -393,20 +393,23 @@ impl Application {
393
393
394 /// Refresh theme after config change
394 /// Refresh theme after config change
395 fn refresh_theme(&mut self, config: &Config) -> Result<(), Error> {
395 fn refresh_theme(&mut self, config: &Config) -> Result<(), Error> {
396− if let Some(theme) = config.theme.clone() {
396+ let true_color = config.editor.true_color || crate::true_color();
397− let true_color = self.true_color();
397+ let theme = config
398+ .theme
399+ .as_ref()
398− let theme = self
400+ .and_then(|theme| {
399− .theme_loader
401+ self.theme_loader
400− .load(&theme)
402+ .load(theme)
403+ .map_err(|e| {
401− .map_err(|err| anyhow::anyhow!("Failed to load theme `{}`: {}", theme, err))?;
404+ log::warn!("failed to load theme `{}` - {}", theme, e);
402−
405+ e
406+ })
407+ .ok()
403− if true_color || theme.is_16_color() {
408+ .filter(|theme| (true_color || theme.is_16_color()))
404− self.editor.set_theme(theme);
409+ })
405− } else {
410+ .unwrap_or_else(|| self.theme_loader.default_theme(true_color));
406− anyhow::bail!("theme requires truecolor support, which is not available")
407− }
408− }
409
411
412+ self.editor.set_theme(theme);
410 Ok(())
413 Ok(())
411 }
414 }
412
415
@@ -431,10 +434,6 @@ impl Application {
431 }
434 }
432 }
435 }
433
436
434− fn true_color(&self) -> bool {
435− self.config.load().editor.true_color || crate::true_color()
436− }
437−
438 #[cfg(windows)]
437 #[cfg(windows)]
439 // no signal handling available on windows
438 // no signal handling available on windows
440 pub async fn handle_signals(&mut self, _signal: ()) {}
439 pub async fn handle_signals(&mut self, _signal: ()) {}