update method

bool update(
  1. String markdown
)

Show markdown. Text outside the editing contract (a bare CR or an unpaired surrogate) and content the parser refuses are still this document, so they show as source rather than fail: a read-only view has no edit to reject, and the next text the parser takes renders live again. The editor refuses such text instead, because it must keep a parsable source.

Implementation

bool update(String markdown) {
  if (_snapshot?.source == markdown) return false;
  final current = _snapshot;
  FlarkEditorSnapshot next;
  try {
    validateFlarkSource(markdown);
    next = _projectSnapshot(
      _backend,
      markdown,
      const FlarkSelection.collapsed(0),
      const ProjectionOptions(editableDelimiterRows: false),
      liveLimits,
      syncLimit,
      previous: current is FlarkLiveSnapshot ? current.document : null,
    );
  } on FormatException {
    next = FlarkSourceSnapshot._(markdown, const FlarkSelection.collapsed(0));
  } on FlarkParseException {
    next = FlarkSourceSnapshot._(markdown, const FlarkSelection.collapsed(0));
  }
  _snapshot = next;
  _revision++;
  return true;
}