Keep correct cursor pos when resizing. Fixes #2018.