delete method

Delta delete(
  1. int index,
  2. int length
)

Deletes length of characters from this document starting at index.

This method applies heuristic rules before modifying this document and produces a NotusChange with source set to ChangeSource.local.

Returns an instance of Delta actually composed into this document.

Implementation

Delta delete(int index, int length) {
  assert(index >= 0 && length > 0);
  // TODO: need a heuristic rule to ensure last line-break.
  final change = heuristics.applyDeleteRules(this, index, length);
  if (change.isNotEmpty) {
    // Delete rules are allowed to prevent the edit so it may be empty.
    compose(change, ChangeSource.local);
  }
  return change;
}