@@ -187,9 +187,15 @@ public function progressBlock(string $text, string $progress = 'running', string
187187 $ width = min ($ this ->terminal ->getWidth (), $ this ->maxWidth );
188188 $ dotLength = $ width - 5 - strlen (strip_tags ($ text .$ progress ));
189189
190+ // In case it doesn't fit the screen, add enough lines with dots
191+ $ textLength = strlen (strip_tags ($ text )) + 20 ;
192+ $ dotLength += floor ($ textLength / $ width ) * $ width ;
193+
194+ $ this ->consoleProgress = $ progress ;
195+
190196 $ this ->output ->write (sprintf (
191197 " $ text <fg=gray>%s</> <fg= $ color>%s</> " ,
192- str_repeat ('. ' , ( $ dotLength < 1 ) ? 1 : $ dotLength ),
198+ str_repeat ('. ' , max ( 1 , $ dotLength) ),
193199 strtoupper ($ progress )
194200 ));
195201 }
@@ -199,14 +205,17 @@ public function progressBlock(string $text, string $progress = 'running', string
199205 *
200206 * @return void
201207 */
202- public function closeProgressBlock (string $ text = 'done ' , string $ color = 'green ' )
208+ public function closeProgressBlock (string $ progress = 'done ' , string $ color = 'green ' )
203209 {
204- $ this ->deleteChars (20 );
210+ $ deleteSize = max (strlen ($ this ->consoleProgress ?? '' ), strlen ($ progress )) + 1 ;
211+ $ newDotSize = $ deleteSize - strlen ($ progress ) - 1 ;
212+
213+ $ this ->deleteChars ($ deleteSize );
205214
206215 $ this ->output ->write (sprintf (
207216 "<fg=gray>%s</> <fg= $ color>%s</> " ,
208- str_repeat ('. ' , 19 - strlen ( $ text )) ,
209- strtoupper ($ text ),
217+ $ newDotSize > 0 ? str_repeat ('. ' , $ newDotSize ) : '' ,
218+ strtoupper ($ progress ),
210219 ));
211220 $ this ->newLine ();
212221 }
0 commit comments