From e0f2d011615783f694628a69a4fb917311ad58f1 Mon Sep 17 00:00:00 2001 From: Christopher Cartland Date: Mon, 18 Aug 2025 16:04:26 -0700 Subject: [PATCH] Update _progress_bar.py This library crashes when total_imaginary_width == 0.0 because the modulo cannot divide by zero. Although it's probably a bug if the a user of the library is trying to render something with width == 0, the library doesn't need to crash here. We can use start = 0.0 as a reasonable value for a width of 0. --- src/textual/widgets/_progress_bar.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/textual/widgets/_progress_bar.py b/src/textual/widgets/_progress_bar.py index 669df2e90d..e11861e291 100644 --- a/src/textual/widgets/_progress_bar.py +++ b/src/textual/widgets/_progress_bar.py @@ -127,7 +127,11 @@ def render_indeterminate(self) -> RenderResult: else: speed = 30 # Cells per second. # Compute the position of the bar. - start = (speed * self._clock.time) % (2 * total_imaginary_width) + start = ( + (speed * self._clock.time) % (2 * total_imaginary_width) + if total_imaginary_width != 0.0 + else 0.0 + ) if start > total_imaginary_width: # If the bar is to the right of its width, wrap it back from right to left. start = 2 * total_imaginary_width - start # = (tiw - (start - tiw))