Smart fold and unfold cursor position