Skip to content

Commit

Permalink
fix padding with coloures strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed May 19, 2019
1 parent 4a4dc67 commit 53cded7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/utils/utils.go
Expand Up @@ -33,10 +33,11 @@ func SplitLines(multilineString string) []string {

// WithPadding pads a string as much as you want
func WithPadding(str string, padding int) string {
if padding-len(str) < 0 {
uncoloredStr := Decolorise(str)
if padding < len(uncoloredStr) {
return str
}
return str + strings.Repeat(" ", padding-len(str))
return str + strings.Repeat(" ", padding-len(uncoloredStr))
}

// ColoredString takes a string and a colour attribute and returns a colored
Expand Down

0 comments on commit 53cded7

Please sign in to comment.