Ordered record of edit deltas that lets sync consumers catch up independently.
The buffer process applies edits to the document immediately. This struct remembers the resulting Minga.Buffer.EditDelta values for systems that sync incrementally, such as highlighting or language tooling. Each consumer keeps its own cursor, so one consumer reading changes does not steal them from another consumer.
This module is pure state. It does not broadcast events, adjust decorations, or know about GenServer calls.
Summary
Functions
Returns sequence-qualified changes without mutating or registering a consumer.
Clears all recorded changes and consumer cursors without rewinding sequence.
Returns globally pending changes in edit order and clears that legacy pending list.
Returns the first sequence still retained, or the next sequence when empty.
Creates an empty change log.
Records a new edit delta.
Returns the latest recorded sequence.
Returns changes unseen by consumer in edit order and advances that consumer's cursor.
Types
@type consumer() :: atom()
@type entry() :: {sequence(), Minga.Buffer.EditDelta.t()}
@type sequence() :: non_neg_integer()
@type sequence_changes() :: {:ok, sequence(), [Minga.Buffer.EditDelta.t()]} | {:reset_required, sequence()}
@opaque t()
@type unseen_changes() :: {:ok, [Minga.Buffer.EditDelta.t()]} | :reset_required
Functions
@spec changes_since(t(), sequence()) :: sequence_changes()
Returns sequence-qualified changes without mutating or registering a consumer.
Clears all recorded changes and consumer cursors without rewinding sequence.
@spec drain_pending_changes(t()) :: {[Minga.Buffer.EditDelta.t()], t()}
Returns globally pending changes in edit order and clears that legacy pending list.
Returns the first sequence still retained, or the next sequence when empty.
@spec new() :: t()
Creates an empty change log.
@spec record_change(t(), Minga.Buffer.EditDelta.t()) :: t()
Records a new edit delta.
Returns the latest recorded sequence.
@spec take_unseen_changes(t(), consumer()) :: {unseen_changes(), t()}
Returns changes unseen by consumer in edit order and advances that consumer's cursor.
Returns :reset_required when older retained entries were compacted before the consumer caught up. Callers must full-sync their downstream state in that case.