Restore cursor position after formatting