From d05ca3db0b914fe27df0595391b938b8d3abc48f Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 29 Aug 2024 07:14:20 +0200 Subject: [PATCH] fix: handle small terminal width closes #10572 --- freqtrade/optimize/hyperopt_output.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/freqtrade/optimize/hyperopt_output.py b/freqtrade/optimize/hyperopt_output.py index eb6e2c509..74aa8e547 100644 --- a/freqtrade/optimize/hyperopt_output.py +++ b/freqtrade/optimize/hyperopt_output.py @@ -60,11 +60,16 @@ class HyperoptOutput: max_rows: Optional[int] = None if self._streaming: - ts = get_terminal_size()[1] + ts = get_terminal_size() # Get terminal size. # Account for header, borders, and for the progress bar. # This assumes that lines don't wrap. - max_rows: Optional[int] = -(ts - 6) if self._streaming else None + if ts.columns < 148: + # If the terminal is too small, we can't display the table properly. + # We will halve the number of rows to display. + max_rows = -(int(ts.lines / 2) - 6) + else: + max_rows = -(ts.lines - 6) self.__init_table() for r in self._results[max_rows:]: