summaryrefslogtreecommitdiffstats
path: root/pkg/utils/formatting.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-10-24 18:18:08 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-10-30 18:26:06 +1100
commitb04b45724671a1f13f1faf277007c76df6ca9fed (patch)
tree97fe33732edcf4372cc13ef1e85a83cabb3422e1 /pkg/utils/formatting.go
parent6457800748f4769b96508da5054208b28a0dee6e (diff)
fix yet another issue with indentation
Diffstat (limited to 'pkg/utils/formatting.go')
-rw-r--r--pkg/utils/formatting.go9
1 files changed, 5 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
}