Skip to main content

Module patch

Module patch 

Source
Expand description

The change currency: Edit / Patch and the one position-mapping function every derived position flows through.

A Patch is the sole record of “what changed” produced by a committed transaction. Selections, diagnostics, snippet stops, and find matches all move through Patch::map_offset — one function, one contract — so a position is never maintained two ways and cannot drift out of sync.

Mapping is prefix-preserving: an edit deletes [s, e) and inserts L bytes at s; a position inside the overwritten prefix keeps its absolute offset, only the deleted tail beyond the insert clamps, and a pure deletion collapses its interior to s. Bias matters at exactly one place — a position sitting on the insertion point.

Structs§

Edit
One span’s coordinate transform: the pre-edit byte range old became the post-edit byte range new. For a single edit old.start == new.start; in a multi-edit Patch, new is already in final post-edit coordinates.
Patch
An ordered set of Edits — the one change currency.