Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: on clear, correctly flush with carriage return #134

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion progressbar.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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