Mithil467 / mitype

Typing speed test in terminal
http://mithil467.github.io/mitype
GNU General Public License v3.0
415 stars 62 forks source link

A minor issue with indexes #105

Closed davleop closed 3 years ago

davleop commented 3 years ago

Subject of the issue

I would go look at it now, but I am busy, but here is the traceback of the error I've come across.

Your environment

Ubuntu 16.04.7 LTS Mitype version 0.2.3 Python 3.8.11 GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)

Steps to reproduce

I finished almost all of the typing test, but then when I missed the period around the end and hit and then tried backspacing and correcting my mistake, it crashed with the following:

Traceback (most recent call last): File "/home/user1/.pyenv/versions/3.8.11/bin/mitype", line 33, in sys.exit(load_entry_point('mitype==0.2.3', 'console_scripts', 'mitype')()) File "/home/user1/.pyenv/versions/3.8.11/lib/python3.8/site-packages/mitype/app.py", line 85, in init curses.wrapper(self.main) File "/home/user1/.pyenv/versions/3.8.11/lib/python3.8/curses/init.py", line 105, in wrapper return func(stdscr, *args, **kwds) File "/home/user1/.pyenv/versions/3.8.11/lib/python3.8/site-packages/mitype/app.py", line 117, in main self.typing_mode(win, key) File "/home/user1/.pyenv/versions/3.8.11/lib/python3.8/site-packages/mitype/app.py", line 176, in typing_mode self.key_printer(win, key) File "/home/user1/.pyenv/versions/3.8.11/lib/python3.8/site-packages/mitype/app.py", line 276, in key_printer self.update_state(win) File "/home/user1/.pyenv/versions/3.8.11/lib/python3.8/site-packages/mitype/app.py", line 372, in update_state self.text[i], IndexError: string index out of range

Expected behaviour

Not error.

Actual behaviour

Error.

Your proposed fix (if any)

If I am able to get to it soon, I'll edit this section later.

welcome[bot] commented 3 years ago

Thank you for opening your first issue in this project! A contributor should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

Mithil467 commented 3 years ago

Thanks for the issue! @davleop Can confirm this issue exists on the latest master. https://github.com/Mithil467/mitype/blob/63cf85813133ef33ff174c50e9041ff801767b8a/mitype/app.py#L277-L284

This can be reproduced by typing extra (incorrect) characters towards the end of the text, like you mentioned missing a fullstop.

A valid solution could be to not append the index if it is out of bound - https://github.com/Mithil467/mitype/blob/63cf85813133ef33ff174c50e9041ff801767b8a/mitype/app.py#L253

Prathamesh010 commented 3 years ago

I would like to work on this issue!

Mithil467 commented 3 years ago

Thank you for your interest in contributing to mitype!