Skip to content

Commit

Permalink
fix: don't color if there are no options in the alternate array
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlazar committed Apr 15, 2022
1 parent 7bcee18 commit f912170
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions table.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ func (t Table) WriteTable(w io.Writer, c *Config) error {
}
fmt.Fprintln(w)

color := c.Color && c.AlternateColors && len(c.AltColorCodes) > 1
for n, row := range t.Rows {
if c.Color && c.AlternateColors {
if color {
fmt.Fprint(w, c.AltColorCodes[n%len(c.AltColorCodes)])
}
if c.ShowIndex {
Expand All @@ -78,7 +79,7 @@ func (t Table) WriteTable(w io.Writer, c *Config) error {
for i, v := range row {
fmt.Fprintf(w, " %s", runewidth.FillRight(v, spacing[i]))
}
if c.Color && c.AlternateColors {
if color {
fmt.Fprint(w, ansi.Reset)
}
fmt.Fprintln(w)
Expand Down

0 comments on commit f912170

Please sign in to comment.