Fixing movement of cursor and the text during resize for real this time

Redesigned logic for resizing