Add nice error message for zero-length files.
brian6932 opened this issue · 1 comments
brian6932 commented
So with c7b7717, the feature does work, however I noticed 3 issues:
- It seems to end early, calculating the total keypresses incorrectly
- When a typo is made in a word, instead of the word being turned red, the whole text becomes red
- Pressing
esc
, thenr
causes a panic, this should probably just restart the current promptthread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', src\ui.rs:98:26 stack backtrace: 0: 0x7ff7846c74b2 - <unknown> 1: 0x7ff7846deaeb - <unknown> 2: 0x7ff7846c36ca - <unknown> 3: 0x7ff7846c71fb - <unknown> 4: 0x7ff7846c9949 - <unknown> 5: 0x7ff7846c95cb - <unknown> 6: 0x7ff7846ca078 - <unknown> 7: 0x7ff7846c9f6e - <unknown> 8: 0x7ff7846c7e99 - <unknown> 9: 0x7ff7846c9c20 - <unknown> 10: 0x7ff7846f0ae5 - <unknown> 11: 0x7ff7846f0c77 - <unknown> 12: 0x7ff78463ec9d - <unknown> 13: 0x7ff78463f8fe - <unknown> 14: 0x7ff78463bc52 - <unknown> 15: 0x7ff78462a976 - <unknown> 16: 0x7ff78462a9a1 - <unknown> 17: 0x7ff7846be0ce - <unknown> 18: 0x7ff78463c8fc - <unknown> 19: 0x7ff7846e5ae0 - <unknown> 20: 0x7ffe279f117e - BaseThreadInitThunk 21: 0x7ffe289042db - RtlUserThreadStart
max-niederman commented
I suspect that this is because the file is 0 words long, causing ttyper to error because it assumes there's always a current word.
I'll address this in v2 (#83), but if anyone is interesting in implementing a nice error message for this in v1, that would be a good first issue.