top: Don't crash on small terminals

Summary:
`eden top` would previously crash if its terminal window was resized too small,
due to incorrectly specifying a negative padding width in a format specifier.

Reviewed By: xavierd

Differential Revision: D44564714

fbshipit-source-id: 936f346ce7e7f5cb0f18cdbffa269cb0fd06be91
This commit is contained in:
Mark Shroyer 2023-03-31 14:35:41 -07:00 committed by Facebook GitHub Bot
parent d8bd987a4d
commit 78031282c6

View File

@ -708,7 +708,8 @@ class Top:
requests_for_type = "N/A"
elif requests_for_type == STATS_NOT_IMPLEMENTED:
requests_for_type = ""
requests_for_type_display = f"{requests_for_type:>{request_count_size-1}} "
request_count_padding = max(request_count_size - 1, 0)
requests_for_type_display = f"{requests_for_type:>{request_count_padding}} "
# duration of the longest request
longest_request = metrics[RequestMetric.MAX_DURATION] # s