TL;DR: Using some IMEs, like Gboard, when adding a char directly after a word (without space) the IME will replace the whole word tric
with trick
instead of just appending the c
.
Detailed asnwer: How IMEs work with editors.
How some IMEs dictate commands to editors
IMEs communicate with editors (e.g. EditText) through InputConnection interface where they can send commands following user input, and get current text.
Gboard IME works in the following way:
- gets text before and after cursor
- detects the currently "composing" word and asks the editor to highlight and remember it (usually results in the word being underlined - check screenshot below)
Being aware of the currently composing word enables many features like suggesting words or auto-correcting spelling.
- Whenever a char is inputted by the user, Gboard will ask the editor to set the currently composing text to a new value, i.e. replace
trick
by tricky
- After a space is inputted, Gboard will do a final replace of currently composing region, eventually auto-correcting spelling
- Currently composing region is reset to the next word.
This unfortunately breaks what we would normally expect from SPAN_EXCLUSIVE_EXCLUSIVE
.