Fixes#13266
Keep search text and its selection range synchronized as a single
state transition.
Deleting or replacing a search term could leave a String.Index range
from the old value attached to the text field. Applying that range
could crash the app.
Clear selection before publishing new text.