Skip to content

Commit 2e9fb11

Browse files
committed
fix(theme): clear per-pane OSC colors on alt-screen exit
OSC 4/10/11 overrides outlived the process that set them. A theme change left them intact, so an editor re-querying colors on reopen (helix) reverted the pane to the old theme. Clear a pane's OSC overrides when it leaves the alternate screen — the full-screen app that set them is exiting. Running apps keep their overrides across a theme change; only the bg reset is pushed to the frontend so the OSC-11-derived window background follows.
1 parent 6194297 commit 2e9fb11

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

  • rio-backend/src/crosswords

rio-backend/src/crosswords/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,10 @@ impl<U: EventListener> Crosswords<U> {
15121512

15131513
// Reset alternate screen contents.
15141514
self.inactive_grid.reset_region(..);
1515+
} else {
1516+
// Leaving alt screen: the full-screen app that set any OSC
1517+
// color overrides is exiting, so drop them.
1518+
self.reset_all_colors();
15151519
}
15161520

15171521
mem::swap(
@@ -1535,6 +1539,23 @@ impl<U: EventListener> Crosswords<U> {
15351539
self.mark_fully_damaged();
15361540
}
15371541

1542+
/// Drop every per-pane OSC color override. The bg reset is pushed
1543+
/// to the frontend so the window background (derived from OSC 11)
1544+
/// follows. Caller is responsible for damage.
1545+
fn reset_all_colors(&mut self) {
1546+
let bg = NamedColor::Background as usize;
1547+
let had_bg_override = self.colors[bg].is_some();
1548+
1549+
self.colors = TermColors::default();
1550+
1551+
if had_bg_override {
1552+
self.event_proxy.send_event(
1553+
RioEvent::ColorChange(self.route_id, bg, None),
1554+
self.window_id,
1555+
);
1556+
}
1557+
}
1558+
15381559
#[inline]
15391560
pub fn mark_line_damaged(&mut self, line: Line) {
15401561
let line_idx = line.0 as usize;

0 commit comments

Comments
 (0)