diff options
Diffstat (limited to 'vendor/anstream/src')
-rw-r--r-- | vendor/anstream/src/adapter/wincon.rs | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/vendor/anstream/src/adapter/wincon.rs b/vendor/anstream/src/adapter/wincon.rs index 71edc4cf5..de3da6502 100644 --- a/vendor/anstream/src/adapter/wincon.rs +++ b/vendor/anstream/src/adapter/wincon.rs @@ -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) => { @@ -244,7 +245,7 @@ mod test { .collect::<Vec<_>>(); let mut state = WinconBytes::new(); let actual = state.extract_next(input.as_bytes()).collect::<Vec<_>>(); - assert_eq!(expected, actual); + assert_eq!(expected, actual, "{input:?}"); } #[test] @@ -287,6 +288,21 @@ mod test { verify(&input, expected); } + #[test] + fn ansi256_colors() { + // termcolor only supports "brights" via these + let input = format!( + "Hello {}!", + "world".color(owo_colors::XtermColors::UserBrightYellow) + ); + let expected = vec![ + (anstyle::Style::default(), "Hello "), + (anstyle::Ansi256Color(11).on_default(), "world"), + (anstyle::Style::default(), "!"), + ]; + verify(&input, expected); + } + proptest! { #[test] #[cfg_attr(miri, ignore)] // See https://github.com/AltSysrq/proptest/issues/253 |