handleSelectAll function

bool handleSelectAll(
  1. FluentDocument document
)

Implementation

bool handleSelectAll(FluentDocument document) {
  final root = document.content;
  final cursor = document.cursor;

  if (root.nodes.isEmpty) return false;

  // Use the document-cached stop rail instead of rebuilding O(n).
  final stops = document.caretStops;
  if (stops.isEmpty) return false;

  // Select from first to last stop
  final firstStop = stops.first;
  final lastStop = stops.last;

  cursor.moveTo(firstStop.fragmentId, firstStop.offset);
  cursor.focusTo(lastStop.fragmentId, lastStop.offset);

  // Sync SelectionManager to show visual selection
  _syncSelectionManager(document);

  // Select-all does NOT mutate content: cursor-only update.
  document.cursorOnlyUpdate();
  return true;
}