Adjust selection when text is updated