Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 74547f3

Browse files
authored
Text output: removed trailing spaces for right-padding of tables (#2290)
* Simplified table.Render method * Removed right padding from tables
1 parent 0af0b44 commit 74547f3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎table/table.go‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package table
1818
import (
1919
"fmt"
2020
"math"
21+
"strings"
2122
)
2223

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

128129
res := ""
129130
for _, row := range t.rows {
130-
separator := ""
131+
line := ""
131132
for x, cell := range row.cells {
132133
selectedWidth := widths[x]
133134
if x < len(t.columnsWidthMode) {
@@ -141,11 +142,13 @@ func (t *Table) Render() string {
141142
if selectedWidth < minimum[x] {
142143
selectedWidth = minimum[x]
143144
}
144-
res += separator
145-
res += cell.Pad(selectedWidth)
146-
separator = " "
145+
if x > 0 {
146+
line += " "
147+
}
148+
line += cell.Pad(selectedWidth)
147149
}
148-
res += "\n"
150+
151+
res += strings.TrimRight(line, " ") + "\n"
149152
}
150153
return res
151154
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /