Make the insert mode highlight sticky

This CL fixes the issue that in some Apps the insert mode highlight
is applied to the entire text range after an editing. This is caused
by App call text.replace(0, text.length(), newText) after each edit.
Here the newText is usually a copy of text that has different spans.
And Apps use this trick to update the spans on the text. However, it
tricks the insert mode to think that the entire string is replaced.
This Cl fixed the issue by making the highlight range sticky when the
text replace range covers the highlight range.

Bug: 355137282
Test: atest InsertModeTransformationMethod
Flag: com.android.text.flags.insert_mode_highlight_range

Change-Id: I46dd0f22db0287a51a6f8fda6ea2c8514c2e4b63
3 files changed