jedib0t / go-pretty

Table-writer and more in golang!
MIT License
3.02k stars 119 forks source link

Background color of last row continues to bottom border of table #248

Closed rhysd closed 1 year ago

rhysd commented 1 year ago

Describe the bug

Background color of last row unexpectedly continues to the bottom border of rendered table. See the repro below.

To Reproduce

package main

import (
    "os"

    "github.com/jedib0t/go-pretty/v6/table"
    "github.com/jedib0t/go-pretty/v6/text"
)

func main() {
    t := table.NewWriter()
    t.SetOutputMirror(os.Stdout)
    t.AppendHeader(table.Row{"Hello"})
    t.AppendRow(table.Row{"World"})
    t.SetStyle(table.StyleRounded)
    t.Style().Color.Row = text.Colors{text.Reset, text.BgHiBlack}
    t.Render()
}

Expected behavior Only the "World" row is highlighted with BgHiBlack.

Screenshots

image

As you see, the highlighted color continues in bottom border of table ╰───────╯

Software (please complete the following information):

Additional context

I at first saw this issue in https://github.com/google/osv-scanner and noticed the issue happened in this package.

image
jedib0t commented 1 year ago

This is a known issue. I'd probably have to change the code to skip coloring the separators altogether, but it may look uglier than this. :( Do you want to try coloring the columns individually using ColumnConfig.Colors instead of t.Style().Color.Row?

rhysd commented 1 year ago

@jedib0t Thanks for confirming that. I could not find any other issue ticket tracking this. Should I leave this issue open or close?

jedib0t commented 1 year ago

I meant I know of this issue. 😊 Sorry for the confusion.

Leave it open if the workaround doesn't satisfy you. I'll see if I can skip coloring all the separators instead.

jedib0t commented 1 year ago

@rhysd I've cut a tag for you with an option to turn off coloring borders and separators: https://github.com/jedib0t/go-pretty/releases/tag/v6.4.4

rhysd commented 1 year ago

@jedib0t Thank you! I'll have a look.

rhysd commented 1 year ago
image

I confirmed. Thank you again.