Codebase list golang-github-vbauerster-mpb / d4cb20d
make sure spinner's frame not skipped Vladimir Bauer 7 years ago
2 changed file(s) with 6 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2525 type spinnerDecorator struct {
2626 WC
2727 frames []string
28 count uint
2829 complete *string
2930 }
3031
3233 if st.Completed && d.complete != nil {
3334 return d.FormatMsg(*d.complete)
3435 }
35 frame := d.frames[st.Current%int64(len(d.frames))]
36 frame := d.frames[d.count%uint(len(d.frames))]
37 d.count++
3638 return d.FormatMsg(frame)
3739 }
3840
2121
2222 type spinnerFiller struct {
2323 frames []string
24 count uint
2425 alignment SpinnerAlignment
2526 }
2627
2728 func (s *spinnerFiller) Fill(w io.Writer, width int, stat *decor.Statistics) {
2829
29 frame := s.frames[stat.Current%int64(len(s.frames))]
30 frame := s.frames[s.count%uint(len(s.frames))]
3031 frameWidth := utf8.RuneCountInString(frame)
3132
3233 if width < frameWidth {
4243 case SpinnerOnRight:
4344 io.WriteString(w, strings.Repeat(" ", rest)+frame)
4445 }
46 s.count++
4547 }