Commit Graph
2 Commits
Author SHA1 Message Date
dualfroz c92652a003 fix: include escape codes in byte counts from Print, Printf
Color.Print and Color.Printf return the number of bytes written, but only
counted the bytes of the formatted operands. The SGR escape sequence written
before them and the reset sequence written after were silently dropped from
the count, so the returned n was always short whenever color output was
active.

Fprint and Fprintf had the identical bug and were already fixed in cbda2c3d
by switching from the void Set/unset() pair to setWriter/unsetWriter, which
return the byte counts of the escape sequences so they can be accumulated.
That fix was never applied to Print and Printf, which still call Set() and
unset() and discard what they write.

Give Print and Printf the same setWriter/unsetWriter treatment as Fprint and
Fprintf. The private unset() method has no remaining callers after this
change and is removed.

Add TestColor_Print and TestColor_Printf, mirroring the existing
TestColor_Fprint/TestColor_Fprintf byte-count assertions.
2026-09-04 08:25:41 +02:00
upstream baec7b1239 Upstream gookit/color state of the touched files before a10b061e0b 2026-09-04 08:25:41 +02:00