Skip to content

Commit

Permalink
progress: fix rendering issue with PositionLeft (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedib0t committed Aug 10, 2018
1 parent 1d81963 commit 8db8efb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/demo-progress/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func trackSomething(pw progress.Writer, idx int64) {

pw.AppendTracker(&tracker)

c := time.Tick(time.Millisecond * 100)
c := time.Tick(time.Millisecond * 250)
for !tracker.IsDone() {
select {
case <-c:
Expand Down
6 changes: 4 additions & 2 deletions progress/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func (p *Progress) renderTracker(out *strings.Builder, t *Tracker) {
pInProgress = p.style.Chars.Finished50
} else if pFinishedDotsFraction > 0.25 {
pInProgress = p.style.Chars.Finished25
} else if pFinishedDotsFraction == 0 {
pInProgress = ""
}

p.renderTrackerProgress(out, t, p.style.Colors.Tracker.Sprintf("%s%s%s%s%s",
Expand All @@ -128,7 +130,7 @@ func (p *Progress) renderTrackerProgress(out *strings.Builder, t *Tracker, track
out.WriteString(p.style.Colors.Tracker.Sprint(trackerStr))
}
p.renderTrackerStats(out, t)
out.WriteString("\n")
out.WriteRune('\n')
} else {
p.renderTrackerPercentage(out, t)
if !p.hideTracker {
Expand All @@ -139,7 +141,7 @@ func (p *Progress) renderTrackerProgress(out *strings.Builder, t *Tracker, track
out.WriteString(p.style.Colors.Message.Sprint(p.style.Options.Separator))
out.WriteString(p.style.Colors.Message.Sprint(t.Message))
out.WriteString(p.style.Colors.Message.Sprint(t.Message))
out.WriteRune(' ')
out.WriteRune('\n')
}
}

Expand Down
2 changes: 1 addition & 1 deletion progress/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func generateWriter() Writer {
pw.SetSortBy(SortByNone)
pw.SetStyle(StyleDefault)
pw.SetTrackerPosition(PositionRight)
pw.SetUpdateFrequency(time.Millisecond * 100)
pw.SetUpdateFrequency(time.Millisecond * 50)
pw.Style().Colors = StyleColors{}
pw.Style().Options = StyleOptions{
DoneString: "done!",
Expand Down

0 comments on commit 8db8efb

Please sign in to comment.