sayanarijit / tui-input

TUI input library supporting multiple backends, tui-rs and ratatui
MIT License
123 stars 12 forks source link

Systematic crash when deleting input containing unicode characters #4

Closed MrCasCode closed 2 years ago

MrCasCode commented 2 years ago

Hi @sayanarijit

Thank you very much for this amazing crate.

I'm encountering a systematic crash whenever I write strings containing unicode characters.

It's crashing on input.rs: 115: self.value.remove(self.cursor);

A minimum reproducible example is:

let mut string = "¡¡¡¡".to_string();
string.remove(1);

thread 'main' panicked at 'byte index 1 is not a char boundary; it is inside '¡' (bytes 0..2) of¡¡¡¡'

For now just creating the issue to signal the weakness. I'll create a PR if I find a clean solution

sayanarijit commented 2 years ago

Thanks for reporting. Released 0.2.0 with the fix. EDIT: 0.2.1 fixes insertion as well.