diff --git a/bar.go b/bar.go index c4bcdbe..ddfb4d5 100644 --- a/bar.go +++ b/bar.go @@ -17,6 +17,8 @@ tip byte leftEnd byte rightEnd byte + + lastFrame []byte incrCh chan int redrawReqCh chan chan []byte @@ -162,7 +164,7 @@ b.redrawReqCh <- respCh return string(<-respCh) } - return "" + return string(b.lastFrame) } func (b *Bar) server(wg *sync.WaitGroup) { @@ -207,8 +209,11 @@ respCh <- int(100 * float64(current) / float64(b.total)) case <-b.flushedCh: if completed && !b.isDone() { + stat := &Statistics{b.total, current, timeElapsed, tpie} + b.lastFrame = b.draw(stat, buf, appendFuncs, prependFuncs) close(b.done) wg.Done() + return } case <-b.stopCh: close(b.done) diff --git a/progress.go b/progress.go index 531ad7a..c54a316 100644 --- a/progress.go +++ b/progress.go @@ -137,9 +137,6 @@ cw = cwriter.New(w) case op, ok := <-p.op: if !ok { - for _, b := range bars { - b.Stop() - } t.Stop() return }