Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions halo/halo.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def text(self, text):
Defines the text value for spinner
"""
self._text = self._get_text(text)
self._text_index = 0

@property
def text_color(self):
Expand Down
13 changes: 13 additions & 0 deletions tests/test_halo.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,19 @@ def test_text_animation(self):

self.assertRegex(output[-1], pattern)

def test_text_index_reset_on_text_change(self):
"""Test the text frame index is reset when the text is reassigned
"""
long_text = 'This is a text that it is too long. In fact, it exceeds the eighty column standard ' \
'terminal width, which forces the text frame renderer to animate it. ' * 6
spinner = Halo(text=long_text, spinner='dots', stream=self._stream, animation='marquee')

spinner._text_index = len(spinner._text['frames']) - 1
spinner.text = 'short'

self.assertEqual(spinner._text_index, 0)
self.assertEqual(spinner.text_frame(), 'short')

def test_context_manager(self):
"""Test the basic of basic spinners used through the with statement.
"""
Expand Down