Closed Lilja closed 5 years ago
The last character of a bounce animation is never visible. Consider the case where the terminal width is 78 and the text width is 82. Animating with bounce will not show the last character.
0767ac1
0.0.17
pip freeze
N/A
The last character should be shown.
I've written a test case that demonstrates the fault
def test_bounce_animation(self): def filler_text(n_chars: int): return "_" * n_chars text = "{}abc".format(filler_text(80)) expected_frames_without_appended_spinner = [ "{}".format(filler_text(78)), "{}".format(filler_text(78)), "{}".format(filler_text(78)), "{}a".format(filler_text(77)), "{}ab".format(filler_text(76)), "{}abc".format(filler_text(75)), "{}abc".format(filler_text(75)), "{}ab".format(filler_text(76)), "{}a".format(filler_text(77)), "{}".format(filler_text(78)), "{}".format(filler_text(78)), "{}".format(filler_text(78)), ] # Prepend the actual spinner expected_frames = [ "{0} {1}".format(frames[idx % frames.__len__()], frame) for idx, frame in enumerate(expected_frames_without_appended_spinner) ] spinner = Halo(text, animation="bounce", stream=self._stream) spinner.start() # Sleep a full bounce cycle time.sleep(1.2) spinner.stop() output = self._get_test_output() zippped_expected_and_actual_frame = zip(expected_frames, output) for multiple_frames in zippped_expected_and_actual_frame: expected_frame, actual_frame = multiple_frames self.assertEquals(expected_frame, actual_frame)
This will fail. However, changing https://github.com/manrajgrover/halo/blob/0767ac1d6e827cbe53347d9141eb3667b7b61019/halo/halo.py#L280
to
for x in range(0, text_length - terminal_width + 1):
resolves the test.
Description
The last character of a bounce animation is never visible. Consider the case where the terminal width is 78 and the text width is 82. Animating with bounce will not show the last character.
System settings
0767ac1
/0.0.17
pip freeze
output: https://pastebin.com/iR79NRAAError
N/A
Expected behaviour
The last character should be shown.
Steps to recreate
I've written a test case that demonstrates the fault
This will fail. However, changing https://github.com/manrajgrover/halo/blob/0767ac1d6e827cbe53347d9141eb3667b7b61019/halo/halo.py#L280
to
resolves the test.
People to notify