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

Handle newline in msg and empty msg #540

Merged
merged 1 commit into from
May 11, 2023

Conversation

RDruon
Copy link
Contributor

@RDruon RDruon commented May 11, 2023

Using println() with a new line at the beginning of the message trigger some artifacts, see below:

newline_artifact.rs

use indicatif::ProgressBar;

fn main() {
    let pb = ProgressBar::new(1024);
    pb.inc(1);
    pb.println("\nShould be a new line before this message and no duplicate progress bar");
    pb.finish_with_message("done");
}

Output on main:
image
Output with this patch:
image


Using println() with an empty string does not trigger new line:
empty_msg.rs

use indicatif::ProgressBar;

fn main() {
    let pb = ProgressBar::new(1024);
    pb.inc(1);
    pb.println("");
    pb.println("There should an empty line before this message");
    pb.finish_with_message("done");
}

Output on main:
image

Output with this patch:
image

New test in render.rs showcase both issue

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me, modulo the formatting issue found in CI.

@RDruon
Copy link
Contributor Author

RDruon commented May 11, 2023

This makes sense to me, modulo the formatting issue found in CI.

I fixed the format issue

@chris-laplante chris-laplante merged commit 59cd606 into console-rs:main May 11, 2023
@djc djc mentioned this pull request May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants