-
Notifications
You must be signed in to change notification settings - Fork 242
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
ProgressBar scrolls instead of redraws when ◎
character is present
#497
Comments
Sorry for regressing this! Since you already have a working version and a failing version, would you be able to git bisect this? Pinpointing which change broke this would probably make it a bunch easier to diagnose. |
Edit: Adding links to make it easier to jump around: |
Hmm, are you specifically setting alignment in your templates? It seems like we don't correctly measure the text width in the face of non-ASCII characters when we try to align. |
Here's the code for our ProgressBar: let progress_bar = indicatif::ProgressBar::new(42);
progress_bar.set_draw_target(ProgressDrawTarget::stdout());
progress_bar.set_style(
ProgressStyle::default_spinner()
.template("{spinner:.green} {wide_msg}")
.expect("ProgresStyle::template direct input to be correct"),
);
progress_bar.enable_steady_tick(Duration::from_millis(100)); And progress_bar.set_message(format!(
"{}{}| \
Processed Slot: {} | Confirmed Slot: {} | Finalized Slot: {} | \
Full Snapshot Slot: {} | Incremental Snapshot Slot: {} | \
Transactions: {} | {}", And the whole output looks like this:
|
So that doesn't look like any alignment is involved. Would you be able to debug some more? Now that we know the regressing commit it shouldn't be too hard to put some debug stuff in there to figure out what's up. |
Yep, can do! |
This will exhibit the issue: diff --git a/src/style.rs b/src/style.rs
index 98b9c05..6e3b202 100644
--- a/src/style.rs
+++ b/src/style.rs
@@ -894,13 +894,13 @@ mod tests {
let mut buf = Vec::new();
let style = ProgressStyle::with_template("{wide_msg}").unwrap();
- state.message = TabExpandedString::NoTabs("abcdefghijklmnopqrst".into());
+ state.message = TabExpandedString::NoTabs("abcdefghij◎klmnopqrst".into());
style.format_state(&state, &mut buf, WIDTH);
assert_eq!(&buf[0], "abcdefghij");
buf.clear();
let style = ProgressStyle::with_template("{wide_msg:>}").unwrap();
- state.message = TabExpandedString::NoTabs("abcdefghijklmnopqrst".into());
+ state.message = TabExpandedString::NoTabs("abcdefghij◎klmnopqrst".into());
style.format_state(&state, &mut buf, WIDTH);
assert_eq!(&buf[0], "klmnopqrst"); Looks like calling Line 701 in d54fb0e
The docs for If you call So the unicode width calculation by It looks like By using Maybe these crates can be of use? |
Right, so the code that trims the output if it's about to overflow the terminal width is wrong. So if
Does that make sense? Should also add a test to make sure we don't regress this. |
Yes, this sounds reasonable to me. Thanks! |
I think I might also be running into this with one of my projects. The two messages with an emoji cause the line to overflow by one char. |
I tried to improve the situation with #647 but I can't quite get it to work (and/or my terminal isn't capable enough?). Happy if someone wants to help out (maybe submit a PR against my PR). |
I am experiencing my ProgressBar scrolling instead of truncating/redrawing when I shrink my terminal's window.
I am running on a remote Ubuntu server. Terminal is Mac's iTerm2, with and without tmux. The ProgressBar's template uses
{wide_msg}
, so I expect the progress bar to truncate text as the window sizes decreases.This only manifests when I shrink my past the
◎
character. If this character is not present in the message, the progress bar works as expected regardless of how small I shrink my terminal's window.Also, version v0.16.2 does not exhibit this behavior; it works as expected.
I've tried v0.17.1 and v0.17.2. With v0.17.2 I also tried using the "improved_unicode" feature. None of these resulted in correct behavior.
Here's more information in an issue I have against my repo where I debugged this:
solana-labs/solana#29158
If it's helpful, I can get a screen capture and/or a set of steps to reproduce the issue (may be slightly involved though). Thanks in advance!
The text was updated successfully, but these errors were encountered: