szn

Bug 67 — writeCell writes character with wrong colors after attribute reset emits \x1b[m

67. writeCell writes character with wrong colors after attribute reset emits \x1b[m

File: src/tty/tty.zig:366–379 Severity: CRITICAL Status: ✅ FIXED — reordered writeCell to setAttributes before setForeground/setBackground.

pub fn writeCell(self: *Term, cell: Cell) Error!void {
    try self.setForeground(cell.fg);    // emits \x1b[38;2;Rm
    try self.setBackground(cell.bg);    // emits \x1b[48;2;Rm
    try self.setAttributes(cell.attr);  // may emit \x1b[m (full SGR reset!)
    try self.write(buf[0..encoded_len]); // character rendered with DEFAULT colors

setAttributes can emit \x1b[m (full SGR reset), wiping the fg/bg colors just set. The character is rendered with default terminal colors, not the cell’s intended colors. Affects every cell where attributes transition from non-zero to zero.