fix problem where replacing text with text of greater length could result in the end of the text not showing