Fix caret position bug during resizing.