Is your feature request related to a problem?
On every attribute change, the renderer tears down all SGR state with a blanket \x1b[0m before re-emitting, instead of resetting only the channel that changed (fg vs bg). A red-background cell followed by a default cell generates ...\x1b[48;2;255;0;0mA\x1b[0m... rather than a clean \x1b[49m, resulting in more bytes to process and unnecessary broken foreground sections.
Describe the solution you'd like
Diff the previous and current cell per channel and emit targeted resets when that channel actually changes: \x1b[39m to return the foreground to default, \x1b[49m for the background. Unchanged channels should remain intact across the run. The visible result is identical; the output is smaller and color runs stay continuous.
Describe alternatives you've considered
Keeping the blanket reset and trimming elsewhere doesn't help—the reset is exactly what forces the re-emit. The per-channel diff has to live in emit_attr, alongside the lastfg/lastbg state it already tracks.
Additional context
Failing test case on nm/repro/targeted-sgr-resets (test · diff).
The change likely lives in emit_attr (src/clayterm.c:90)—the blanket reset at :95, foreground/background emit at :114/:125.
Is your feature request related to a problem?
On every attribute change, the renderer tears down all SGR state with a blanket
\x1b[0mbefore re-emitting, instead of resetting only the channel that changed (fg vs bg). A red-background cell followed by a default cell generates...\x1b[48;2;255;0;0mA\x1b[0m...rather than a clean\x1b[49m, resulting in more bytes to process and unnecessary broken foreground sections.Describe the solution you'd like
Diff the previous and current cell per channel and emit targeted resets when that channel actually changes:
\x1b[39mto return the foreground to default,\x1b[49mfor the background. Unchanged channels should remain intact across the run. The visible result is identical; the output is smaller and color runs stay continuous.Describe alternatives you've considered
Keeping the blanket reset and trimming elsewhere doesn't help—the reset is exactly what forces the re-emit. The per-channel diff has to live in
emit_attr, alongside thelastfg/lastbgstate it already tracks.Additional context
Failing test case on
nm/repro/targeted-sgr-resets(test · diff).The change likely lives in
emit_attr(src/clayterm.c:90)—the blanket reset at:95, foreground/background emit at:114/:125.