pub struct Delta {
pub start: usize,
pub old: String,
pub new: String,
}Expand description
A reversible edit between two adjacent buffer states, expressed as a single spanning replacement in char-offset space on the rope.
The index space is ropey char offsets throughout — never bytes — so
multi-byte UTF-8 round-trips (a byte offset could split a codepoint). In the
PARENT state chars[start .. start + old.chars().count()] == old; replacing
that region with new yields the CHILD state, and swapping the two inverts
it. A whole undo group collapses to the one region spanning its edits
(common-prefix / common-suffix diff); a Vec<Delta> for disjoint regions is
an acceptable future generalization, but one spanning region is all Phase 3a
needs.
Fields§
§start: usizeChar offset of the first differing char (the common-prefix length).
old: StringChars present in the PARENT but not the CHILD (removed going forward).
new: StringChars present in the CHILD but not the PARENT (inserted going forward).