toggleFoldAtCursor method

bool toggleFoldAtCursor()

Toggles the fold at the primary cursor, moving onto the header if hidden.

Implementation

bool toggleFoldAtCursor() {
  _refreshEditorStateSnapshot();
  final line = _editorState.cursor.line;
  var range = folds.foldStartingAt(line);
  if (range == null) {
    for (final candidate in folds.ranges) {
      if (line >= candidate.startLine && line <= candidate.endLine) {
        range = candidate;
        break;
      }
    }
  }
  if (range == null) return false;
  folds.toggle(range.startLine);
  if (!_moveHiddenCursorsToFoldHeaders()) _syncCoreState();
  return true;
}