Steps to reproduce
- In VE standalone, edit <ul><li><u>12</u></li><li><s>34</s></li></ul>
- Select from '2' to '3' inclusive
- Type with an IME that doesn't trigger keydown/keypress events (e.g. press backtick twice in Firefox on Linux with UK extended WinKeys).
Observed behaviour
Corruption - DOM merge and linear model merge are out of sync
Expected behaviour
DOM and linear model remain in sync
Explanation
This is quite a wide issue: the IME will generally corrupt the document whenever it causes a native merge of branch nodes, e.g. if the user merely selects across a paragraph boundary and types. The problem is that ve.ce.Surface#handleInsertion is not being called. It is needed to perform emulated deletion of certain selections. But with IME event models we don't have an even that forewarns us of an upcoming insertion, so we never trigger this.
Solution
We should probably trigger handleInsertion on compositionstart. It has certain side effects:
- Deletion would happen earlier than strictly necessary. But presumably the user does want to delete the selection or they wouldn't have triggered compositionstart, so this is minor.
- Minor premature commits would occur in some IMEs that don't select the candidate text. But experimentally it doesn't seem to be a very common issue. In any case, it's better than the current major corruption possible in a wide range of IMEs.