We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a934721 commit aa7686aCopy full SHA for aa7686a
progress.go
@@ -119,17 +119,25 @@ func (p *progressBarImpl) write(s string) error {
119
}
120
121
func (p *progressBarImpl) erase(n int) {
122
- for i := 0; i < n; i++ {
123
- p.writer.Write([]byte{'\b'})
+ // Don't use '\b' - it's only move cursor to back
+ b := make([]byte, 0, n+2)
124
+ b = append(b, '\r')
125
+ for i := 0; i < n; i ++ {
126
+ b = append(b, ' ')
127
128
129
+ p.writer.Write(b)
130
131
132
func (p *progressBarImpl) done() {
133
p.wMutex.Lock()
134
defer p.wMutex.Unlock()
135
- p.erase(p.writtenLen)
- fmt.Fprintln(p.writer, p.final)
136
+ if p.final != "" {
137
+ p.erase(p.writtenLen)
138
+ fmt.Fprintln(p.writer, p.final)
139
+ }
140
+
141
142
143
func (p *progressBarImpl) output() string {
0 commit comments