spinner: don't restart the spinner when .start() is called

Previously, when we called spinner.start(), we would automatically call
.stop() first to reset it.

Unfortunately, after calling stop(), the spinner mutates its visual
representation to become invisible using .set_text("").

This is a problem because after disappearing, the spinner does not
reappear instantly, which causes visual glitches depending on how often
we redraw the screen.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2024-03-18 15:36:17 +01:00
parent 0987dc5a7a
commit 592714279c
1 changed files with 2 additions and 0 deletions

View File

@ -75,6 +75,8 @@ class Spinner(Text):
await asyncio.sleep(self.rate)
def start(self):
if self._spin_task is not None:
return
if self.debug:
log.debug("starting spinner %s", id(self))
self.stop()