@@ -259,19 +259,20 @@ def message_with_progress(downloadable, future, message)
259259 tty_width = Tty . width
260260 return message unless tty_width . positive?
261261
262+ available_width = tty_width - 2
262263 fetched_size = downloadable . fetched_size
263- return message if fetched_size . blank?
264+ return message [ 0 , available_width ] . to_s if fetched_size . blank?
264265
265266 size_length = 5
266267 unit_length = 2
267268 size_formatting_string = "%<size>#{ size_length } .1f%<unit>#{ unit_length } s"
268- size , unit = disk_usage_readable_size_unit ( fetched_size )
269+ size , unit = disk_usage_readable_size_unit ( fetched_size , per_thousand : true )
269270 formatted_fetched_size = format ( size_formatting_string , size :, unit :)
270271
271272 formatted_total_size = if future . fulfilled?
272273 formatted_fetched_size
273274 elsif ( total_size = downloadable . total_size )
274- size , unit = disk_usage_readable_size_unit ( total_size )
275+ size , unit = disk_usage_readable_size_unit ( total_size , per_thousand : true )
275276 format ( size_formatting_string , size :, unit :)
276277 else
277278 # fill in the missing spaces for the size if we don't have it yet.
@@ -280,11 +281,11 @@ def message_with_progress(downloadable, future, message)
280281
281282 max_phase_length = 11
282283 phase = format ( "%-<phase>#{ max_phase_length } s" , phase : downloadable . phase . to_s . capitalize )
283- progress = "#{ formatted_fetched_size } /#{ formatted_total_size } "
284- additional_padding_length = max_phase_length + size_length + unit_length - 1
285- message_length = tty_width - progress . length - additional_padding_length
284+ progress = " [ #{ phase } #{ formatted_fetched_size } /#{ formatted_total_size } ] "
285+ message_length = available_width - progress . length
286+ return message [ 0 , available_width ] . to_s unless message_length . positive?
286287
287- "#{ message [ 0 , message_length ] . to_s . ljust ( message_length ) } [ #{ phase } #{ progress } ] "
288+ "#{ message [ 0 , message_length ] . to_s . ljust ( message_length ) } #{ progress } "
288289 end
289290
290291 class Spinner
0 commit comments