search method

List<int> search(
  1. Pattern other
)

Search the whole document for any substring matching the pattern Returns the offsets that matches the pattern

Implementation

List<int> search(Pattern other) {
  final matches = <int>[];
  for (final node in _root.children) {
    if (node is Line) {
      _searchLine(other, node, matches);
    } else if (node is Block) {
      for (final line in Iterable.castFrom<dynamic, Line>(node.children)) {
        _searchLine(other, line, matches);
      }
    } else {
      throw StateError('Unreachable.');
    }
  }
  return matches;
}