From 311872839a7ad8dbb368b78d275f78989aa602ab Mon Sep 17 00:00:00 2001 From: Sergii Bogomolov Date: Tue, 15 Jun 2021 17:54:30 +0200 Subject: [PATCH] Leave a clear line after spinner is stopped Currently after spinner is stopped it might leave behind the last symbol that was printed. This happens because '\b' is non-destructive in many terminal emulators. If '\n' is printed after spinner is done - the last printed symbol will remain printed (instead of an empty line). This happens because '\n' also happens to be non-destructive. VS Code is one example of such terminal emulator. --- click_spinner/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/click_spinner/__init__.py b/click_spinner/__init__.py index 21e1053..2e941f9 100644 --- a/click_spinner/__init__.py +++ b/click_spinner/__init__.py @@ -33,7 +33,10 @@ def init_spin(self): self.stream.flush() self.stop_running.wait(0.25) self.stream.write('\b') - self.stream.flush() + + self.stream.write(' ') + self.stream.write('\b') + self.stream.flush() def __enter__(self): self.start()