Skip to content

Allow to manually redraw the progress bar #688

@ClementNerma

Description

@ClementNerma

Hi!

I've been using this crate a lot and it's been amazing, thanks for making it <3

I only have one problem currently, which is that the progress bar doesn't update visually when position changes happen too quickly. Here is an example:

use indicatif::ProgressBar;

static LEN: u64 = 10000;

fn main() {
    let pb = ProgressBar::new(LEN);

    for _ in 0..LEN {
        pb.inc(1);
        // pb.tick();
    }

    std::thread::sleep(std::time::Duration::from_secs(10000));
}

If you run this program, you will see when we reach the sleep portion that the program only has a part of the progress bar filled. Every time you run the program, the final position is a little bit different.

Uncommenting the pb.tick(); line worsens the problem as the bar gets stuck on position 10 / 10000 (I understand the problem with the previous code why not sure why for this one?)

So I'd like to be able to manually refresh the progress bar and redraw it. Something like pb.redraw() or pb.refresh(). It would obviously greatly increase latency and this example code would become a lot slower, but that would solve the problem I have.

I didn't find a way to do this currently ; would it be possible to add this feature?

Many thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions