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

Progress Bars over 80 characters move up the screen when stdout is redirected #609

Closed
jparris opened this issue Dec 1, 2023 · 4 comments

Comments

@jparris
Copy link

jparris commented Dec 1, 2023

Hi There,

I've encountered a case where if the progress bar length is over 80 characters and stdout is redirected the progress bar will move up the screen overwriting previous output. As can bee seen in the screen recording. Below is screen recording and code snippet.

Reproduction

ProgressBarMovesUP.mov

Code

Note: The progress line only hit's 81 characters and displays the behavior when we 100 iterations.

use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use std::thread;
use std::time::Duration;

fn main() {
    let num_jobs: usize = 500;

    let display_manager = MultiProgress::new();
    let pb = display_manager.add(ProgressBar::new(num_jobs as u64));
    pb.set_style(
        ProgressStyle::with_template(
            &format!("{{spinner}} [{{elapsed_precise}}] {{bar:.cyan}} {{pos}}/{{len}} This is a long comment in the progress "),
        )
        .expect("Could not create progress bar style"),
    );
    for _ in 0..num_jobs {
        pb.inc(1);
        thread::sleep(Duration::from_millis(10));
    }

    let _ = display_manager.println("Progress Bar Completed.");
}
@djc
Copy link
Member

djc commented Dec 4, 2023

I think this might be the same as #606?

@jparris
Copy link
Author

jparris commented Dec 5, 2023

Hi @djc ,

I just ran a quick experiment using the branch for PR #608 which fixes issue #606 and was able to reproduce the issue.

Cargo.toml for the code snippet above.

name = "indicatif_issue"
version = "0.1.0"
edition = "2021"

[dependencies]
indicatif = {git = "https://github.com/tgolsson/indicatif", branch = "ts/real-len" }

@tgolsson
Copy link
Contributor

tgolsson commented Dec 5, 2023

Might be related to console-rs/console#185?

@jparris
Copy link
Author

jparris commented Dec 5, 2023

Might be related to console-rs/console#185?

@tgolsson great suggestionm, when I used your PR branch it resolved the issue 🎉 . I'm going to close this issue.

@jparris jparris closed this as completed Dec 5, 2023
@djc djc reopened this Dec 6, 2023
@djc djc closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 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

No branches or pull requests

3 participants