File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed
Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ struct State<'cfg> {
3131 throttle : Throttle ,
3232 last_line : Option < String > ,
3333 fixed_width : Option < usize > ,
34+ last_pbar : u8 ,
3435}
3536
3637struct Format {
@@ -100,6 +101,7 @@ impl<'cfg> Progress<'cfg> {
100101 throttle : Throttle :: new ( ) ,
101102 last_line : None ,
102103 fixed_width : progress_config. width ,
104+ last_pbar : 255 ,
103105 } ) ,
104106 }
105107 }
@@ -214,13 +216,12 @@ impl<'cfg> State<'cfg> {
214216 // return back to the beginning of the line for the next print.
215217 self . try_update_max_width ( ) ;
216218 if let Some ( pbar) = self . format . progress ( cur, max) {
219+ let prog = ( ( cur as f32 ) / ( max as f32 ) * 100.0 ) as u8 ;
220+ if self . last_pbar != prog {
221+ write ! ( self . config. shell( ) . err( ) , "{}" , ProgressCode :: Normal ( prog) ) ?;
222+ self . last_pbar = prog;
223+ }
217224 self . print ( & pbar, msg) ?;
218- let prog = ( cur as f32 ) / ( max as f32 ) * 100.0 ;
219- write ! (
220- self . config. shell( ) . err( ) ,
221- "{}" ,
222- ProgressCode :: Normal ( prog as u8 )
223- ) ?;
224225 }
225226 Ok ( ( ) )
226227 }
You can’t perform that action at this time.
0 commit comments