diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/anstream/src | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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 |