From f2113c1fc79110c5f243a39cb5ac03590b67fed9 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 21 Nov 2023 12:48:20 -0500 Subject: [PATCH] fix potential error in progress bar calculation --- progress/bar.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/progress/bar.go b/progress/bar.go index b32aae610..a482bfe48 100644 --- a/progress/bar.go +++ b/progress/bar.go @@ -95,7 +95,10 @@ func (b *Bar) String() string { } // 44 is the maximum width for the stats on the right of the progress bar - suf.WriteString(strings.Repeat(" ", 44-suf.Len()-len(timing))) + pad := 44 - suf.Len() - len(timing) + if pad > 0 { + suf.WriteString(strings.Repeat(" ", pad)) + } suf.WriteString(timing) // add 3 extra spaces: 2 boundary characters and 1 space at the end