Fix cursor position after resize