From 6452e2ecb83ae03b1c504e09b6ca3ce9868d0c45 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Tue, 21 Nov 2023 12:07:25 -0500 Subject: [PATCH] fix cases where progress bar would not be fixed size --- progress/bar.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/progress/bar.go b/progress/bar.go index d9d243f6..b32aae61 100644 --- a/progress/bar.go +++ b/progress/bar.go @@ -89,17 +89,13 @@ func (b *Bar) String() string { fmt.Fprintf(&suf, ")") - elapsed := time.Since(b.started) var timing string if stats.value > b.initialValue && stats.value < b.maxValue { - timing = fmt.Sprintf("[%s:%s]", formatDuration(elapsed), formatDuration(stats.remaining)) + timing = fmt.Sprintf("[%s:%s]", formatDuration(time.Since(b.started)), formatDuration(stats.remaining)) } // 44 is the maximum width for the stats on the right of the progress bar - if suf.Len() < 44 { - suf.WriteString(strings.Repeat(" ", 44-suf.Len()-len(timing))) - } - + suf.WriteString(strings.Repeat(" ", 44-suf.Len()-len(timing))) suf.WriteString(timing) // add 3 extra spaces: 2 boundary characters and 1 space at the end