Skip to content

Commit

Permalink
Fix panic with footer columns less than header columns
Browse files Browse the repository at this point in the history
Adopted from olekukonko#228
  • Loading branch information
meain committed Oct 9, 2024
1 parent df64c4b commit f7b26e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion table.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ func (t *Table) printFooter() {
max := t.rs[footerRowIdx]

// Print Footer
for i := 0; i < (len(t.cs) - len(t.footers)); i++ {
for len(t.cs)-len(t.footers) > 0 {
lines := t.parseDimension(" ", len(t.footers), footerRowIdx)
t.footers = append(t.footers, lines)
}
Expand Down
4 changes: 2 additions & 2 deletions table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1309,13 +1309,13 @@ func TestLessFooterColumnsThanHeaders(t *testing.T) {
data = [][]string{
{"1", "2", "3"},
}
footer = []string{"a", "b"}
footer = []string{"a"}
want = `+---+---+---+
| A | B | C |
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| A | B | |
| A | | |
+---+---+---+
`
)
Expand Down

0 comments on commit f7b26e0

Please sign in to comment.