charmbracelet / bubbletea

A powerful little TUI framework 🏗
MIT License
27.85k stars 805 forks source link

textinput only takes the first char with IME #20

Closed Zym3Gen closed 4 years ago

Zym3Gen commented 4 years ago

e.g. with the example textinput component:

while typing: image

actually got: image

meowgorithm commented 4 years ago

Thanks for the report. Which operating system are you running?

Zym3Gen commented 4 years ago

Oh, sorry to mention: it's on macOS 10.15.7 (19H2). And the terminal is iTerm2 Build 3.3.12.

meowgorithm commented 4 years ago

Thanks! Also, what are the exact input settings you're using?

Zym3Gen commented 4 years ago

I use Sogou Pinyin IME, a popular one among Chinese users.

The program I tested is an example you provided: https://github.com/charmbracelet/bubbletea/blob/master/examples/textinput/main.go

mritd commented 4 years ago

The same problem under Rime IME

image

There are also problems under the Mac native IME

image

Obsidian6s commented 4 years ago

Broken with Apple Default SC Pinyin IME as well:

image

image

mritd commented 4 years ago

After checking the code, the problem seems to be caused by the readInput method in key.go. The utf8.DecodeRune method always decodes the first rune, causing subsequent data loss.

But I don’t understand the specific logic and how to fix it.

meowgorithm commented 4 years ago

This is all very helpful; thank you for all the reports. It's really important to us that we sort this one out — I'll keep this thread updated with progress.

meowgorithm commented 4 years ago

Hi everyone. Just a note that we're implementing a fix for this and expect to have it merged in the next few days. We'll continue to keep this thread updated with progress.

meowgorithm commented 4 years ago

Hi everyone! Just a note that this is fixed in master. We'll be doing releases on Bubble Tea and Bubbles tomorrow that will contain this fix.

Thanks again for flagging this, and let us know if you have anymore trouble with IME.