bczsalba / pytermgui

Python TUI framework with mouse support, modular widget system, customizable and rapid terminal markup language and more!
https://ptg.bczsalba.com
MIT License
2.16k stars 53 forks source link

[BUG] IndexError in multiline InputField #105

Closed xezo360hye closed 1 year ago

xezo360hye commented 1 year ago

Describe the bug When using multiline InputField, there are at least 2 ways to get IndexError, both of them lead to app being freezed or crashed which is annoying

To Reproduce Steps to reproduce the behavior:

  1. Press Enter while there is no characters in the input field
  2. On a newline, try to remove last character. If the previous line is not empty, pressing backspace will raise an error, though app does not exit and just freezes

Expected behavior It should normally edit text

Screenshots image image

System information

PyTermGUI version 7.3.0

System details:
    Python version: 3.10.9
    $TERM:          xterm-256color
    $COLORTERM:     truecolor
    Color support:  ColorSystem.TRUE
    OS Platform:    Linux-6.1.1-arch1-1-x86_64-with-glibc2.36

Possible cause Both errors happen in input_field.py when trying to get self._lines[...] and is related to current row

Possible solution Sanity check for index (row) and array length

bczsalba commented 1 year ago

Sorry that took a while, should be fixed now!