Skip to content

Commit

Permalink
fix(table): fixed table when a column contained a whitespace at the s…
Browse files Browse the repository at this point in the history
…tart or end
  • Loading branch information
MarvinJWendt committed May 14, 2023
1 parent d16af50 commit a3e5fe9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions table_printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package pterm

import (
"encoding/csv"
"github.com/pterm/pterm/internal"
"io"
"strings"

"github.com/pterm/pterm/internal"
)

// DefaultTable contains standards, which can be used to print a TablePrinter.
Expand Down Expand Up @@ -183,8 +184,8 @@ func (p TablePrinter) Srender() (string, error) {
c.lines = strings.Split(cRaw, "\n")
c.height = len(c.lines)
for _, l := range c.lines {
if internal.GetStringMaxWidth(l) > c.width {
c.width = internal.GetStringMaxWidth(l)
if maxWidth := internal.GetStringMaxWidth(l); maxWidth > c.width {
c.width = maxWidth
}
}
r.cells = append(r.cells, c)
Expand Down Expand Up @@ -262,7 +263,7 @@ func (p TablePrinter) renderRow(t table, r row) string {
}

if i < len(c.lines) {
s += strings.TrimSpace(c.lines[i])
s += c.lines[i]
}

if j < len(r.cells)-1 {
Expand Down

0 comments on commit a3e5fe9

Please sign in to comment.