File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -45,14 +45,15 @@ import (
45
45
//
46
46
// The biggest difference is 15 - 2, so we can shrink the 2nd column by 13.
47
47
func (t * Table ) resize () {
48
+ hasHeaders := len (t .headers ) > 0
48
49
rows := dataToMatrix (t .data )
49
50
r := newResizer (t .width , t .height , t .headers , rows )
50
51
r .wrap = t .wrap
51
52
r .borderColumn = t .borderColumn
52
53
r .yPaddings = make ([][]int , len (r .allRows ))
53
54
54
55
var allRows [][]string
55
- if len ( t . headers ) > 0 {
56
+ if hasHeaders {
56
57
allRows = append ([][]string {t .headers }, rows ... )
57
58
} else {
58
59
allRows = rows
@@ -65,7 +66,14 @@ func (t *Table) resize() {
65
66
66
67
for j := range row {
67
68
column := & r .columns [j ]
68
- style := t .styleFunc (i , j )
69
+
70
+ // Making sure we're passing the right index to `styleFunc`. The header row should be `-1` and
71
+ // the others should start from `0`.
72
+ rowIndex := i
73
+ if hasHeaders {
74
+ rowIndex --
75
+ }
76
+ style := t .styleFunc (rowIndex , j )
69
77
70
78
topMargin , rightMargin , bottomMargin , leftMargin := style .GetMargin ()
71
79
topPadding , rightPadding , bottomPadding , leftPadding := style .GetPadding ()
You can’t perform that action at this time.
0 commit comments