console-rs / indicatif

A command line progress reporting library for Rust
MIT License
4.22k stars 238 forks source link

Odd behavior when `ProgressBar::println`ing lengthy messages #591

Open matheus-consoli opened 9 months ago

matheus-consoli commented 9 months ago

When trying to println lengthy messages indicatif forces the terminal to "scroll up" and stop truncating the messages.

To reproduce:

use std::{time::Duration, thread};

use indicatif::ProgressBar; // prepare-0.17-7

fn main() {
    let bar = ProgressBar::new(1);
    bar.set_style(indicatif::ProgressStyle::default_bar().template("{spinner}").unwrap());
    bar.enable_steady_tick(Duration::from_millis(100));

    let mut size = 300;
    loop {
        let msg = "0123456789".repeat(size);
        bar.println("-------");
        bar.println(msg);
        size += 10;
        thread::sleep(Duration::from_millis(500));
    }
}

Recording:

https://github.com/console-rs/indicatif/assets/27595790/27c1798d-e282-431c-a37f-0c8195005e5d

matheus-consoli commented 9 months ago

I'm using the unreleased branch (prepare-0.17-7) - when I use the latest released version (0.17.6) it panics

djc commented 9 months ago

Sorry for the issue! Do you know if this is a regression from some earlier version?

I'm not sure I fully understand what the current behavior is, nor how you would expect it to behave in this case.