diff --git a/docs/changelog.md b/docs/changelog.md index 44a0e587b..d85e9b126 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -30,6 +30,8 @@ As features stabilize some brief notes about them will accumulate here. * It was not possible to specify `freetype_load_flags = 'DEFAULT'`. #4902 * macOS: fallback fonts could select thin or otherwise unspecified font attributes. #4808 +* Changing the palette via escape sequences didn't invalidate caches + correctly, so those escapes sequences wouldn't take effect. #4932 #2635 ### 20240128-202157-1e552d76 diff --git a/term/src/terminalstate/mod.rs b/term/src/terminalstate/mod.rs index c85c10424..ada148039 100644 --- a/term/src/terminalstate/mod.rs +++ b/term/src/terminalstate/mod.rs @@ -919,6 +919,13 @@ impl TerminalState { } } + fn palette_did_change(&mut self) { + self.make_all_lines_dirty(); + if let Some(handler) = self.alert_handler.as_mut() { + handler.alert(Alert::PaletteChanged); + } + } + /// When dealing with selection, mark a range of lines as dirty pub fn make_all_lines_dirty(&mut self) { let seqno = self.seqno; diff --git a/term/src/terminalstate/performer.rs b/term/src/terminalstate/performer.rs index 8562f07aa..80f9d6dd2 100644 --- a/term/src/terminalstate/performer.rs +++ b/term/src/terminalstate/performer.rs @@ -705,9 +705,7 @@ impl<'a> Performer<'a> { self.screen.activate_primary_screen(seqno); self.erase_in_display(EraseInDisplay::EraseScrollback); self.erase_in_display(EraseInDisplay::EraseDisplay); - if let Some(handler) = self.alert_handler.as_mut() { - handler.alert(Alert::PaletteChanged); - } + self.palette_did_change(); } _ => { @@ -944,10 +942,7 @@ impl<'a> Performer<'a> { } } self.implicit_palette_reset_if_same_as_configured(); - if let Some(handler) = self.alert_handler.as_mut() { - handler.alert(Alert::PaletteChanged); - } - self.make_all_lines_dirty(); + self.palette_did_change(); } OperatingSystemCommand::ResetColors(colors) => { @@ -968,9 +963,7 @@ impl<'a> Performer<'a> { } } self.implicit_palette_reset_if_same_as_configured(); - if let Some(handler) = self.alert_handler.as_mut() { - handler.alert(Alert::PaletteChanged); - } + self.palette_did_change(); } OperatingSystemCommand::ChangeDynamicColors(first_color, colors) => { @@ -1025,10 +1018,7 @@ impl<'a> Performer<'a> { idx += 1; } self.implicit_palette_reset_if_same_as_configured(); - if let Some(handler) = self.alert_handler.as_mut() { - handler.alert(Alert::PaletteChanged); - } - self.make_all_lines_dirty(); + self.palette_did_change(); } OperatingSystemCommand::ResetDynamicColor(color) => { @@ -1065,10 +1055,7 @@ impl<'a> Performer<'a> { } } self.implicit_palette_reset_if_same_as_configured(); - if let Some(handler) = self.alert_handler.as_mut() { - handler.alert(Alert::PaletteChanged); - } - self.make_all_lines_dirty(); + self.palette_did_change(); } } } diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs index 2c0cd8bf7..e443969a6 100644 --- a/wezterm-gui/src/termwindow/mod.rs +++ b/wezterm-gui/src/termwindow/mod.rs @@ -1157,6 +1157,10 @@ impl TermWindow { alert: Alert::PaletteChanged, pane_id, } => { + // Shape cache includes color information, so + // ensure that we invalidate that as part of + // this overall invalidation for the palette + self.dispatch_notif(TermWindowNotif::InvalidateShapeCache, window)?; self.mux_pane_output_event(pane_id); } MuxNotification::Alert { @@ -1418,7 +1422,7 @@ impl TermWindow { } } MuxNotification::Alert { - alert: Alert::ToastNotification { .. } | Alert::PaletteChanged { .. }, + alert: Alert::ToastNotification { .. }, .. } | MuxNotification::AssignClipboard { .. } @@ -1433,6 +1437,12 @@ impl TermWindow { | MuxNotification::WorkspaceRenamed { .. } | MuxNotification::Empty | MuxNotification::WindowWorkspaceChanged(_) => return true, + MuxNotification::Alert { + alert: Alert::PaletteChanged { .. }, + .. + } => { + // fall through + } } window.notify(TermWindowNotif::MuxNotification(n));