Skip to content

The title row renders incorrently when set to a non-default style #368

Open
@bagualing

Description

@bagualing

Describe the bug
The title row renders incorrently when set to a non-default style (StyleBold/StyleLight/...). It appears the layout fails to adjust for the width taken up by the title content.

To Reproduce

func main() {
    t := table.NewWriter()
    t.SetOutputMirror(os.Stdout)
    t.SetTitle("SALARY Report")
    t.SetStyle(table.StyleDouble)
    t.AppendHeader(table.Row{"#", "First Name", "Last Name", "Salary"})
    t.AppendRows([]table.Row{
        {1, "Arya", "Stark", 3000},
        {20, "Jon", "Snow", 2000},
    })
    t.AppendSeparator()
    t.AppendRow([]interface{}{300, "Tyrion", "Lannister", 5000})
    t.AppendFooter(table.Row{"", "", "Total", 10000})
    t.Render()
}

Screenshots

┌──────────────────────────────────────────┐
│ SALARY Report                            │
├─────┬────────────┬───────────┬────────┤
│   # │ FIRST NAME │ LAST NAME │ SALARY │
├─────┼────────────┼───────────┼────────┤
│   1 │ Arya       │ Stark     │   3000 │
│  20 │ Jon        │ Snow      │   2000 │
├─────┼────────────┼───────────┼────────┤
│ 300 │ Tyrion     │ Lannister │   5000 │
├─────┼────────────┼───────────┼────────┤
│     │            │ TOTAL     │  10000 │
└─────┴────────────┴───────────┴────────┘

Software (please complete the following information):

  • github.com/jedib0t/go-pretty/v6 v6.6.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions