@@ -321,12 +321,6 @@ impl ProgressStyle {
321
321
}
322
322
} ;
323
323
324
- if buf == "\x00 " {
325
- // Don't expand for wide elements
326
- cur. push_str ( & buf) ;
327
- continue ;
328
- }
329
-
330
324
match width {
331
325
Some ( width) => {
332
326
let padded = PaddedStringDisplay {
@@ -759,4 +753,37 @@ mod tests {
759
753
style. format_state ( & state, & mut buf, WIDTH ) ;
760
754
assert_eq ! ( & buf[ 0 ] , "fghijklmno" ) ;
761
755
}
756
+
757
+ #[ test]
758
+ fn wide_element_style ( ) {
759
+ const CHARS : & str = "=>-" ;
760
+ const WIDTH : u16 = 8 ;
761
+ let pos = Arc :: new ( AtomicPosition :: new ( ) ) ;
762
+ // half finished
763
+ pos. set ( 2 ) ;
764
+ let state = ProgressState :: new ( Some ( 4 ) , pos) ;
765
+ let mut buf = Vec :: new ( ) ;
766
+
767
+ let style = ProgressStyle :: with_template ( "{wide_bar}" )
768
+ . unwrap ( )
769
+ . progress_chars ( CHARS ) ;
770
+ style. format_state ( & state, & mut buf, WIDTH ) ;
771
+ assert_eq ! ( & buf[ 0 ] , "====>---" ) ;
772
+
773
+ buf. clear ( ) ;
774
+ let style = ProgressStyle :: with_template ( "{wide_bar:.red.on_blue/green.on_cyan}" )
775
+ . unwrap ( )
776
+ . progress_chars ( CHARS ) ;
777
+ style. format_state ( & state, & mut buf, WIDTH ) ;
778
+ assert_eq ! (
779
+ & buf[ 0 ] ,
780
+ "\u{1b} [31m\u{1b} [44m====>\u{1b} [32m\u{1b} [46m---\u{1b} [0m\u{1b} [0m"
781
+ ) ;
782
+
783
+ buf. clear ( ) ;
784
+ let mut style = ProgressStyle :: with_template ( "{wide_msg:^.red.on_blue}" ) . unwrap ( ) ;
785
+ style. message = "foobar" . into ( ) ;
786
+ style. format_state ( & state, & mut buf, WIDTH ) ;
787
+ assert_eq ! ( & buf[ 0 ] , "\u{1b} [31m\u{1b} [44m foobar \u{1b} [0m" ) ;
788
+ }
762
789
}
0 commit comments