c92652a003feea3e388d8dffde96096b548f980e
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.
Description
My contributions to gookit/color: 3 commits, 1 merged PRs
82 KiB
0 Stars
1 Watchers
0 Forks
Languages
Go
100%