bool keepLines()

in packages/code_excerpt_updater/lib/src/diff/diff.dart [19:42]


  bool keepLines({Matcher? from, Matcher? to}) {
    if (!_parsed) _parse();
    var matchFound = false;
    if (from != null) {
      while (hunks.isNotEmpty) {
        final hunk = hunks.first;
        if (hunk.dropLinesUntil(from)) {
          matchFound = true;
          break;
        }
        hunks.removeAt(0);
      }
    }
    if (to == null) return matchFound;

    for (var i = 0; i < hunks.length; i++) {
      final hunk = hunks[i];
      if (hunk.dropLinesAfter(to)) {
        hunks.length = i + 1;
        return true;
      }
    }
    return false;
  }