When replacing text, the longest line is not calculated, which results into incorrect horizontal scrolling length