Skip to content

Commit

Permalink
Removed right padding from tables
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Sep 1, 2023
1 parent 51a3222 commit 5614168
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package table
import (
"fmt"
"math"
"strings"
)

// ColumnWidthMode is used to configure columns type
Expand Down Expand Up @@ -127,6 +128,7 @@ func (t *Table) Render() string {

res := ""
for _, row := range t.rows {
line := ""
for x, cell := range row.cells {
selectedWidth := widths[x]
if x < len(t.columnsWidthMode) {
Expand All @@ -143,9 +145,10 @@ func (t *Table) Render() string {
if x > 0 {
line += " "
}
res += cell.Pad(selectedWidth)
line += cell.Pad(selectedWidth)
}
res += "\n"

res += strings.TrimRight(line, " ") + "\n"
}
return res
}
Expand Down

0 comments on commit 5614168

Please sign in to comment.