Minga.RenderModel.Window.LineIdentity (Minga v0.1.0)

Copy Markdown View Source

Persistent durable identity rope for logical buffer lines.

The rope is an AVL tree whose leaves are contiguous source-id runs. Nodes cache logical size and height, so line count is O(1), rank lookup and splices are O(log runs), and unchanged subtrees are structurally shared. Adjacent source-id runs are coalesced after every concatenation.

Summary

Functions

Applies one document edit to the durable identity rope.

Applies edits in order, stopping transactionally when reconciliation fails.

Returns the content epoch owning this identity rope.

Returns the cached AVL height for invariant checks.

Returns the number of current logical lines in O(1).

Creates an identity rope for the current logical-line count.

Starts a new content epoch, intentionally permitting source-id reuse.

Returns the number of contiguous source-id runs for invariant checks.

Returns the durable source id at a zero-based logical-line rank.

Materializes source ids in rank order for diagnostics and tests.

Types

source_id()

@type source_id() :: non_neg_integer()

t()

@opaque t()

transition()

@type transition() :: {:ok, t()} | :reset_required

Functions

apply_edit(identity, delta)

@spec apply_edit(t(), Minga.Buffer.EditDelta.t()) :: transition()

Applies one document edit to the durable identity rope.

apply_edits(identity, deltas)

@spec apply_edits(t(), [Minga.Buffer.EditDelta.t()]) :: transition()

Applies edits in order, stopping transactionally when reconciliation fails.

content_epoch(line_identity)

@spec content_epoch(t()) :: non_neg_integer()

Returns the content epoch owning this identity rope.

height(line_identity)

@spec height(t()) :: non_neg_integer()

Returns the cached AVL height for invariant checks.

line_count(line_identity)

@spec line_count(t()) :: non_neg_integer()

Returns the number of current logical lines in O(1).

new(line_count, content_epoch \\ 1)

@spec new(non_neg_integer(), non_neg_integer()) :: t()

Creates an identity rope for the current logical-line count.

reset(identity, line_count, content_epoch)

@spec reset(t() | nil, non_neg_integer(), non_neg_integer()) :: t()

Starts a new content epoch, intentionally permitting source-id reuse.

run_count(line_identity)

@spec run_count(t()) :: non_neg_integer()

Returns the number of contiguous source-id runs for invariant checks.

source_id(identity, line)

@spec source_id(t(), non_neg_integer()) :: {:ok, source_id()} | :error

Returns the durable source id at a zero-based logical-line rank.

source_ids(line_identity)

@spec source_ids(t()) :: [source_id()]

Materializes source ids in rank order for diagnostics and tests.