diff --git a/progressbar.go b/progressbar.go index 125290a..e0bcf39 100644 --- a/progressbar.go +++ b/progressbar.go @@ -803,6 +803,13 @@ func (p *ProgressBar) Describe(description string) { if p.config.invisible { return } + // if already finished, re-render with the new description + if p.state.finished && !p.config.clearOnFinish && !p.config.useANSICodes { + clearProgressBar(p.config, p.state) + io.Copy(p.config.writer, &p.config.stdBuffer) + renderProgressBar(p.config, &p.state) + return + } p.render() } diff --git a/progressbar_test.go b/progressbar_test.go index c64f660..34ee7b4 100644 --- a/progressbar_test.go +++ b/progressbar_test.go @@ -853,6 +853,22 @@ func TestProgressBar_Describe(t *testing.T) { } } +func TestProgressBar_DescribeAfterFinish(t *testing.T) { + buf := strings.Builder{} + bar := NewOptions(100, + OptionSetDescription("Uploading files"), + OptionShowCount(), + OptionSetWriter(&buf), + OptionSetWidth(10), + ) + for i := 0; i < 100; i++ { + bar.Add(1) + } + bar.Describe("Upload complete") + result := buf.String() + assert.Contains(t, result, "Upload complete") +} + func TestRenderBlankStateWithThrottle(t *testing.T) { buf := strings.Builder{} bar := NewOptions(100, OptionSetWidth(10), OptionSetRenderBlankState(true), OptionThrottle(time.Millisecond), OptionSetWriter(&buf))