Skip to content

Commit

Permalink
Merge pull request #9 from noborus/without-space
Browse files Browse the repository at this point in the history
Maximum width excluding spaces
  • Loading branch information
noborus authored Jul 14, 2024
2 parents 06ec786 + 551b713 commit f34f2aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion guesswidth.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (g *GuessWidth) UpdateMaxWidth(columns []string) []Cols {
}

for n, col := range columns {
width := runewidth.StringWidth(col)
width := runewidth.StringWidth(strings.TrimSpace(col))
if width > g.Widths[n].Width {
g.Widths[n].Width = width
}
Expand Down
26 changes: 13 additions & 13 deletions guesswidth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func TestGuessWidth_ReadAll(t *testing.T) {
},
want2: []Cols{
{6, 1, 1},
{9, 0, 0},
{9, 1, 3},
{5, 0, 0},
{8, 1, 3},
{3, 0, 0},
},
},
Expand All @@ -63,16 +63,16 @@ noborus 721971 0.0 0.0 13716 3524 pts/3 R+ 10:39 0:00 ps aux`)),
{"noborus ", " 721971", " 0.0", " 0.0", " 13716", " 3524", " pts/3 ", " R+ ", " 10:39 ", " 0:00", "ps aux"},
},
want2: []Cols{
{9, 0, 0},
{7, 1, 4},
{5, 1, 4},
{5, 1, 4},
{11, 1, 4},
{7, 1, 4},
{9, 0, 0},
{5, 0, 1},
{8, 0, 0},
{5, 1, 4},
{7, 0, 0},
{6, 1, 4},
{4, 1, 4},
{4, 1, 4},
{10, 1, 4},
{6, 1, 4},
{5, 0, 0},
{4, 0, 1},
{5, 0, 0},
{4, 1, 4},
{25, 0, 0},
},
},
Expand All @@ -93,7 +93,7 @@ noborus 721971 0.0 0.0 13716 3524 pts/3 R+ 10:39 0:00 ps aux`)),
},
want2: []Cols{
{6, 1, 1},
{9, 0, 0},
{5, 0, 0},
{12, 1, 1},
},
},
Expand Down

0 comments on commit f34f2aa

Please sign in to comment.