Skip to content

Commit

Permalink
Merge branch 'master' into printf-no-format
Browse files Browse the repository at this point in the history
  • Loading branch information
briandowns committed Jul 4, 2020
2 parents 35cf572 + 274d177 commit 9cd8896
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions spinner.go
Expand Up @@ -285,10 +285,11 @@ func (s *Spinner) Start() {
case <-s.stopChan:
return
default:
s.mu.Lock()
if !s.active {
s.mu.Unlock()
return
}
s.mu.Lock()
s.erase()

if s.PreUpdate != nil {
Expand All @@ -303,9 +304,9 @@ func (s *Spinner) Start() {
outColor = fmt.Sprintf("\r%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
}
} else {
outColor = fmt.Sprintf("%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
outColor = fmt.Sprintf("\r%s%s%s ", s.Prefix, s.color(s.chars[i]), s.Suffix)
}
outPlain := fmt.Sprintf("%s%s%s ", s.Prefix, s.chars[i], s.Suffix)
outPlain := fmt.Sprintf("\r%s%s%s ", s.Prefix, s.chars[i], s.Suffix)
fmt.Fprint(s.Writer, outColor)
s.lastOutput = outPlain
delay := s.Delay
Expand Down Expand Up @@ -401,6 +402,7 @@ func (s *Spinner) erase() {
for _, c := range []string{"\b", "\127", "\b", "\033[K"} { // "\033[K" for macOS Terminal
fmt.Fprint(s.Writer, strings.Repeat(c, n))
}
fmt.Fprintf(s.Writer, "\r\033[K") // erases to end of line
s.lastOutput = ""
}

Expand Down

0 comments on commit 9cd8896

Please sign in to comment.