Skip to content

Commit

Permalink
table: fix title auto-sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
jedib0t committed Oct 5, 2024
1 parent a2db75a commit 9949e90
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
3 changes: 0 additions & 3 deletions table/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,6 @@ func (t *Table) renderTitle(out *strings.Builder) {
if wm := t.style.Size.WidthMax; wm > 0 && wm < rowLength {
rowLength = wm
}
if wm := t.style.Size.WidthMin; wm > 0 && wm > rowLength {
rowLength = wm
}
if t.style.Options.DrawBorder {
lenBorder := rowLength - text.RuneWidthWithoutEscSequences(t.style.Box.TopLeft+t.style.Box.TopRight)
out.WriteString(colorsBorder.Sprint(t.style.Box.TopLeft))
Expand Down
8 changes: 1 addition & 7 deletions table/render_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,10 @@ func (t *Table) initForRenderMaxRowLength() {
if t.style.Options.DrawBorder {
t.maxRowLength += text.RuneWidthWithoutEscSequences(t.style.Box.Left + t.style.Box.Right)
}

}

func (t *Table) initForRenderPaddedColumns() {
minWidth := t.style.Size.WidthMin
if minWidth == 0 || t.maxRowLength >= minWidth {
return
}

paddingSize := minWidth - t.maxRowLength
paddingSize := t.style.Size.WidthMin - t.maxRowLength
for paddingSize > 0 {
// distribute padding equally among all columns
numColumnsPadded := 0
Expand Down

0 comments on commit 9949e90

Please # to comment.