Skip to content

Commit

Permalink
fix yet another issue with indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Oct 30, 2021
1 parent 6457800 commit b04b457
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/utils/formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
// WithPadding pads a string as much as you want
func WithPadding(str string, padding int) string {
uncoloredStr := Decolorise(str)
if padding < len(uncoloredStr) {
width := runewidth.StringWidth(uncoloredStr)
if padding < width {
return str
}
return str + strings.Repeat(" ", padding-len(uncoloredStr))
return str + strings.Repeat(" ", padding-width)
}

func RenderDisplayStrings(displayStringsArr [][]string) string {
Expand Down Expand Up @@ -55,9 +56,9 @@ func getPadWidths(stringArrays [][]string) []int {
padWidths := make([]int, maxWidth-1)
for i := range padWidths {
for _, strings := range stringArrays {
uncoloredString := Decolorise(strings[i])
uncoloredStr := Decolorise(strings[i])

width := runewidth.StringWidth(uncoloredString)
width := runewidth.StringWidth(uncoloredStr)
if width > padWidths[i] {
padWidths[i] = width
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/utils/formatting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ func TestWithPadding(t *testing.T) {
14,
"hello world ! ",
},
{
"Güçlü",
7,
"Güçlü ",
},
}

for _, s := range scenarios {
Expand Down

0 comments on commit b04b457

Please sign in to comment.