update method

List<String> update(
  1. String source, {
  2. MarkdownBlockRegistry? blockRegistry,
})

Implementation

List<String> update(String source, {MarkdownBlockRegistry? blockRegistry}) {
  if (source == _source && identical(_registry, blockRegistry)) {
    return _segments;
  }
  var from = 0;
  var prefix = const <String>[];
  if (identical(_registry, blockRegistry) &&
      _segments.isNotEmpty &&
      !source.contains('\r') &&
      source.startsWith(_source)) {
    from = _source.lastIndexOf(_segments.last);
    if (from >= 0) {
      prefix = _segments.sublist(0, _segments.length - 1);
    } else {
      from = 0;
    }
  }
  _segments = List.unmodifiable([
    ...prefix,
    ...splitStreamSegments(
      source.substring(from),
      blockRegistry: blockRegistry,
    ),
  ]);
  _source = source;
  _registry = blockRegistry;
  return _segments;
}