You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using a ScrollTextBlock widget instantiated via add_text_block, mouse integration may raise an IndexError.
This occurs when you click below your text. For example:
With an empty TextBlock, click in the middle of the widget to focus it and then start typing.
Write a few lines and click in the middle/end of the text block then start typing again.
An error will be raised as the cursor Y pos is bigger than the number of text lines.
To Reproduce
Steps to reproduce the behavior:
Create an app with a text block
Click in the middle of the widget (below the first empty line) to give him focus.
Start typing.
Expected behavior
Obviously, the error should not be raised. Instead, the cursors should move at the very end of the text to let the user continue typing.
Screenshots
Sorry, I wanted to provide a nice little GIF but I can't do it right now, here is the error thrown:
File "/tmp/recoverpy/env/lib/python3.8/site-packages/py_cui/__init__.py", line 318, in start
curses.wrapper(self._draw)
File "/usr/lib/python3.8/curses/__init__.py", line 105, in wrapper
return func(stdscr, *args, **kwds)
File "/tmp/recoverpy/env/lib/python3.8/site-packages/py_cui/__init__.py", line 1545, in _draw
self._handle_key_presses(key_pressed)
File "/tmp/recoverpy/env/lib/python3.8/site-packages/py_cui/__init__.py", line 1423, in _handle_key_presses
selected_widget._handle_key_press(key_pressed)
File "/tmp/recoverpy/env/lib/python3.8/site-packages/py_cui/widgets.py", line 833, in _handle_key_press
self._insert_char(key_pressed)
File "/tmp/recoverpy/env/lib/python3.8/site-packages/py_cui/ui.py", line 1311, in _insert_char
current_line = self.get_current_line()
File "/tmp/recoverpy/env/lib/python3.8/site-packages/py_cui/ui.py", line 1110, in get_current_line
return self._text_lines[self._cursor_text_pos_y]
IndexError: list index out of range
Describe the bug
When using a
ScrollTextBlock
widget instantiated viaadd_text_block
, mouse integration may raise an IndexError.This occurs when you click below your text. For example:
An error will be raised as the cursor Y pos is bigger than the number of text lines.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Obviously, the error should not be raised. Instead, the cursors should move at the very end of the text to let the user continue typing.
Screenshots
Sorry, I wanted to provide a nice little GIF but I can't do it right now, here is the error thrown:
Environment:
Edit: Opened PR #99 that fixes the issue 😉
The text was updated successfully, but these errors were encountered: