@@ -812,7 +812,7 @@ public function testMultilineFormat()
812812 $ this ->assertEquals (
813813 ">--------------------------- \nfoobar " .
814814 $ this ->generateOutput ("=========>------------------ \nfoobar " ).
815- "\x1B[1A \x1B[1G \x1B[2K " .
815+ "\x1B[1G \x1B [2K \x1B [ 1A \x1B[1G \x1B[2K " .
816816 $ this ->generateOutput ("============================ \nfoobar " ),
817817 stream_get_contents ($ output ->getStream ())
818818 );
@@ -983,7 +983,7 @@ protected function generateOutput($expected)
983983 {
984984 $ count = substr_count ($ expected , "\n" );
985985
986- return ($ count ? sprintf ("\x1B[%dA \x1B [ 1G \x1b[2K " , $ count ) : "\x1B[1G \x1B[2K " ) .$ expected ;
986+ return ($ count ? str_repeat ("\x1B[1G \x1b[2K \x1B [1A " , $ count ) : '' ). "\x1B[1G \x1B[2K " .$ expected ;
987987 }
988988
989989 public function testBarWidthWithMultilineFormat ()
@@ -1095,4 +1095,33 @@ public function testNoWriteWhenMessageIsSame()
10951095 stream_get_contents ($ output ->getStream ())
10961096 );
10971097 }
1098+
1099+ public function testMultiLineFormatIsFullyCleared ()
1100+ {
1101+ $ bar = new ProgressBar ($ output = $ this ->getOutputStream (), 3 );
1102+ $ bar ->setFormat ("%current%/%max% \n%message% \nFoo " );
1103+
1104+ $ bar ->setMessage ('1234567890 ' );
1105+ $ bar ->start ();
1106+ $ bar ->display ();
1107+
1108+ $ bar ->setMessage ('ABC ' );
1109+ $ bar ->advance ();
1110+ $ bar ->display ();
1111+
1112+ $ bar ->setMessage ('A ' );
1113+ $ bar ->advance ();
1114+ $ bar ->display ();
1115+
1116+ $ bar ->finish ();
1117+
1118+ rewind ($ output ->getStream ());
1119+ $ this ->assertEquals (
1120+ "0/3 \n1234567890 \nFoo " .
1121+ $ this ->generateOutput ("1/3 \nABC \nFoo " ).
1122+ $ this ->generateOutput ("2/3 \nA \nFoo " ).
1123+ $ this ->generateOutput ("3/3 \nA \nFoo " ),
1124+ stream_get_contents ($ output ->getStream ())
1125+ );
1126+ }
10981127}
0 commit comments