Skip to content

Commit

Permalink
only move cursor up if pos > 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyng committed Nov 17, 2023
1 parent d6ecaa2 commit 7ea9058
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Progress struct {
}

func NewProgress(w io.Writer) *Progress {
p := &Progress{pos: -1, w: w}
p := &Progress{w: w}
go p.start()
return p
}
Expand Down Expand Up @@ -71,7 +71,10 @@ func (p *Progress) render() error {
p.mu.Lock()
defer p.mu.Unlock()

fmt.Fprintf(p.w, "\033[%dA", p.pos)
if p.pos > 0 {
fmt.Fprintf(p.w, "\033[%dA", p.pos)
}

for _, state := range p.states {
fmt.Fprintln(p.w, state.String())
}
Expand Down

0 comments on commit 7ea9058

Please sign in to comment.