-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.
Description
I tried this code:
fn main() {
let input = String::from("שלום");
// ok (no color)
for ch in input.chars() {
print!("{}", ch);
} println!();
// ok (same color)
for ch in input.chars() {
print!("{}", color(ch));
} println!();
// not ok (mixed colors)
for (i, ch) in input.chars().into_iter().enumerate() {
print!("{}", if i % 2 == 0 { color(ch) } else { color2(ch) });
} println!();
}
fn color(ch: char) -> String {
format!("\x1b[93m{}\x1b[0m", ch)
}
fn color2(ch: char) -> String {
format!("\x1b[96m{}\x1b[0m", ch)
}I expected to see this happen:
- String order is preserved even if inside different ANSI escapes
Instead, this happened:
Meta
rustc --version --verbose:
rustc 1.60.0 (7737e0b5c 2022-04-04)
binary: rustc
commit-hash: 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c
commit-date: 2022-04-04
host: x86_64-pc-windows-msvc
release: 1.60.0
LLVM version: 14.0.0
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.
