vadimdemedes / ink

🌈 React for interactive command-line apps
https://term.ink
MIT License
26.42k stars 594 forks source link

Esoteric bug with handling CMD+V with tabs in userInput #649

Open h0x91b opened 6 months ago

h0x91b commented 6 months ago

Hi there, I found a strange esoteric bug, if I am pasting into terminal anything which starts by '\t' tab character it truncates value of the line and put instead 'i' character, it happens because tab char is less then '\x1a'.

Also if I am pasting big amount of text which tabs on some lines it does the same, but in the middle of text, since sometime it chunks it in the middle of string.

https://github.com/vadimdemedes/ink/blob/168244470cd3e4b85e19b968a55938d013232761/src/parse-keypress.ts#L194-L197

I am suggest to check length of string and do some special handling for symbols like '\t'

i-am-the-slime commented 2 months ago

Yeah, pasting longer strings breaks for me, too, I have to glue a string together from multiple event calls. I have a heuristic based on time.