From 355f3d3975528645dbf04982d0754eaac7d456b6 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 22 Jul 2022 20:23:04 -0700 Subject: [PATCH] fix reloading the global config when the appearance changes We didn't actually update the global config, just the per-window configs, which led to weird stale throwbacks to earlier versions of the config when spawning windows or new panes. Fix that up by explicitly reloading the global config when the window appearance is changed. That isn't ideal as we will reload once per window, but it's "OK". While poking at this, I noticed that the get/set config methods on the termwiztermtab overlay weren't hooked up, and also made a point of calling those for any overlays during a window config reload event, so that per-window overrides are more likely to get picked up and respected. refs: https://github.com/wez/wezterm/issues/2295 --- mux/src/termwiztermtab.rs | 12 +++++++++++- wezterm-gui/src/termwindow/mod.rs | 23 ++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/mux/src/termwiztermtab.rs b/mux/src/termwiztermtab.rs index 60d22c966..ec9146452 100644 --- a/mux/src/termwiztermtab.rs +++ b/mux/src/termwiztermtab.rs @@ -29,7 +29,9 @@ use termwiz::terminal::{ScreenSize, TerminalWaker}; use termwiz::Context; use url::Url; use wezterm_term::color::ColorPalette; -use wezterm_term::{KeyCode, KeyModifiers, MouseEvent, StableRowIndex, TerminalSize}; +use wezterm_term::{ + KeyCode, KeyModifiers, MouseEvent, StableRowIndex, TerminalConfiguration, TerminalSize, +}; struct TermWizTerminalDomain { domain_id: DomainId, @@ -217,6 +219,14 @@ impl Pane for TermWizTerminalPane { Ok(()) } + fn set_config(&self, config: Arc) { + self.terminal.borrow_mut().set_config(config); + } + + fn get_config(&self) -> Option> { + Some(self.terminal.borrow().get_config()) + } + fn perform_actions(&self, actions: Vec) { self.terminal.borrow_mut().perform_actions(actions) } diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index 788d281fb..1812a1e8c 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -792,6 +792,17 @@ impl TermWindow { } WindowEvent::AppearanceChanged(appearance) => { log::debug!("Appearance is now {:?}", appearance); + // This is a bit fugly; we get per-window notifications + // for appearance changes which successfully updates the + // per-window config, but we need to explicitly tell the + // global config to reload, otherwise things that acces + // the config via config::configuration() will see the + // prior version of the config. + // What's fugly about this is that we'll reload the + // global config here once per window, which could + // be nasty for folks with a lot of windows. + // + config::reload(); self.config_was_reloaded(); Ok(true) } @@ -1454,7 +1465,17 @@ impl TermWindow { pane.pane.set_config(Arc::clone(&term_config)); } } - }; + for state in self.pane_state.borrow().values() { + if let Some(overlay) = &state.overlay { + overlay.pane.set_config(Arc::clone(&term_config)); + } + } + for state in self.tab_state.borrow().values() { + if let Some(overlay) = &state.overlay { + overlay.pane.set_config(Arc::clone(&term_config)); + } + } + } if let Some(window) = self.window.as_ref().map(|w| w.clone()) { self.load_os_parameters();