Skip to content

Commit

Permalink
Merge pull request #134 from hexnaught/upstream/issue/130
Browse files Browse the repository at this point in the history
feat: on clear, correctly flush with carriage return
  • Loading branch information
schollz committed Sep 1, 2022
2 parents 614a8d9 + 78c65f3 commit c621381
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion progressbar.go
Expand Up @@ -873,7 +873,7 @@ func clearProgressBar(c config, s state) error {
// fill the empty content
// to overwrite the progress bar and jump
// back to the beginning of the line
str := fmt.Sprintf("\r%s", strings.Repeat(" ", s.maxLineWidth))
str := fmt.Sprintf("\r%s\r", strings.Repeat(" ", s.maxLineWidth))
return writeString(c, str)
// the following does not show correctly if the previous line is longer than subsequent line
// return writeString(c, "\r")
Expand Down
2 changes: 1 addition & 1 deletion progressbar_test.go
Expand Up @@ -606,7 +606,7 @@ func TestProgressBar_Describe(t *testing.T) {
bar.Describe("performing axial adjustments")
bar.Add(10)
rawBuf := strconv.QuoteToASCII(buf.String())
if rawBuf != `"\rperforming axial adjustments 0% | | [0s:0s]\r \rperforming axial adjustments 10% |\u2588 | [0s:0s]"` {
if rawBuf != `"\rperforming axial adjustments 0% | | [0s:0s]\r \r\rperforming axial adjustments 10% |\u2588 | [0s:0s]"` {
t.Errorf("wrong string: %s", rawBuf)
}
}
Expand Down

0 comments on commit c621381

Please sign in to comment.