Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "indicatif"
version = "0.18.1"
version = "0.18.2"
edition = "2021"
rust-version = "1.71"
description = "A progress bar and cli reporting library for Rust"
Expand Down
31 changes: 17 additions & 14 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,20 +781,23 @@ pub fn write_ansi_range(
for (s, is_ansi) in AnsiCodeIterator::new(text) {
if is_ansi {
formatter.write_str(s)?;
} else if pos < end {
for c in s.chars() {
#[cfg(feature = "unicode-width")]
let c_width = c.width().unwrap_or(0);
#[cfg(not(feature = "unicode-width"))]
let c_width = 1;
if start <= pos && pos + c_width <= end {
formatter.write_char(c)?;
}
pos += c_width;
if pos > end {
// no need to iterate over the rest of s
break;
}
continue;
} else if pos >= end {
continue;
}

for c in s.chars() {
#[cfg(feature = "unicode-width")]
let c_width = c.width().unwrap_or(0);
#[cfg(not(feature = "unicode-width"))]
let c_width = 1;
if start <= pos && pos + c_width <= end {
formatter.write_char(c)?;
}
pos += c_width;
if pos > end {
// no need to iterate over the rest of s
break;
}
}
}
Expand Down