diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-24 18:18:08 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-30 18:26:06 +1100 |
commit | b04b45724671a1f13f1faf277007c76df6ca9fed (patch) | |
tree | 97fe33732edcf4372cc13ef1e85a83cabb3422e1 /pkg/utils | |
parent | 6457800748f4769b96508da5054208b28a0dee6e (diff) |
fix yet another issue with indentation
Diffstat (limited to 'pkg/utils')
-rw-r--r-- | pkg/utils/formatting.go | 9 | ||||
-rw-r--r-- | pkg/utils/formatting_test.go | 5 |
2 files changed, 10 insertions, 4 deletions
diff --git a/pkg/utils/formatting.go b/pkg/utils/formatting.go index 8a439bc32..45836da61 100644 --- a/pkg/utils/formatting.go +++ b/pkg/utils/formatting.go @@ -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 { @@ -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 } diff --git a/pkg/utils/formatting_test.go b/pkg/utils/formatting_test.go index 26d560766..66fdfffad 100644 --- a/pkg/utils/formatting_test.go +++ b/pkg/utils/formatting_test.go @@ -25,6 +25,11 @@ func TestWithPadding(t *testing.T) { 14, "hello world ! ", }, + { + "Güçlü", + 7, + "Güçlü ", + }, } for _, s := range scenarios { |