grid: a table-GC sweep that compacts styles leaves the pen pointing at the wrong style #419

Closed
opened 2026-09-25 05:41:27 +09:00 by natsukium · 0 comments
Owner

Found while implementing #409 (PR #418).

TableGc::maybe_sweep (crates/felis-grid/src/table_gc.rs) calls ScreenBuffer::gc_styles directly and discards its compacted result. The daemon's ParseCore::maybe_gc_tables and the client shadow both sweep through it, so after a sweep that compacts the style table, Grid::pen_style is never re-interned and keeps an id that now points at a different entry (or past the end, which resolves to the default pen).

Reproduced on origin/main with a throwaway probe: text printed right after a daemon-path sweep lost its truecolor foreground (Rgb(0,16,0) became Default).

Expected: every sweep path re-interns the pen after a compaction, as Grid::gc_styles does. Pin it with a test that drives TableGc::maybe_sweep into a compaction and then prints with the previous pen.

Found while implementing #409 (PR #418). `TableGc::maybe_sweep` (`crates/felis-grid/src/table_gc.rs`) calls `ScreenBuffer::gc_styles` directly and discards its `compacted` result. The daemon's `ParseCore::maybe_gc_tables` and the client shadow both sweep through it, so after a sweep that compacts the style table, `Grid::pen_style` is never re-interned and keeps an id that now points at a different entry (or past the end, which resolves to the default pen). Reproduced on origin/main with a throwaway probe: text printed right after a daemon-path sweep lost its truecolor foreground (`Rgb(0,16,0)` became `Default`). Expected: every sweep path re-interns the pen after a compaction, as `Grid::gc_styles` does. Pin it with a test that drives `TableGc::maybe_sweep` into a compaction and then prints with the previous pen.
Commenting is not possible because the repository is archived.
No description provided.