Skip to content

Commit

Permalink
fix(stream): Adapt Ansi256 colors for Wincon
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Dec 8, 2023
1 parent 369a57b commit 28e5a96
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions crates/anstream/src/adapter/wincon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ impl anstyle_parse::Perform for WinconCapture {
}

let mut style = self.style;
// param/value differences are dependent on the escape code
let mut state = State::Normal;
let mut r = None;
let mut g = None;
let mut is_bg = false;
for param in params {
let mut state = State::Normal;
let mut r = None;
let mut g = None;
let mut is_bg = false;
for value in param {
match (state, *value) {
(State::Normal, 0) => {
Expand Down Expand Up @@ -294,7 +295,11 @@ mod test {
"Hello {}!",
"world".color(owo_colors::XtermColors::UserBrightYellow)
);
let expected = vec![(anstyle::Style::default(), "Hello world!")];
let expected = vec![
(anstyle::Style::default(), "Hello "),
(anstyle::Ansi256Color(11).on_default(), "world"),
(anstyle::Style::default(), "!"),
];
verify(&input, expected);
}

Expand Down

0 comments on commit 28e5a96

Please sign in to comment.