pub struct TextDelta {
pub before_char_count: usize,
pub after_char_count: usize,
pub edits: Vec<TextDeltaEdit>,
pub undo_group_id: Option<usize>,
}Expand description
A structured description of a document text change.
Fields§
§before_char_count: usizeCharacter count before applying edits.
after_char_count: usizeCharacter count after applying edits.
edits: Vec<TextDeltaEdit>Ordered list of edits that transforms the “before” document into the “after” document.
undo_group_id: Option<usize>If known, the undo group id associated with this change.
Implementations§
Source§impl TextDelta
impl TextDelta
Sourcepub fn merge(first: &TextDelta, second: &TextDelta) -> TextDelta
pub fn merge(first: &TextDelta, second: &TextDelta) -> TextDelta
Merge two consecutive deltas into a single equivalent delta.
first transforms document B0 -> B1 and second transforms B1 -> B2 (i.e. second
was produced against the document state that results from applying first). The returned
delta transforms B0 -> B2.
Because a TextDelta’s edits are defined to be applied in order, each using the
offset valid at the time that edit is applied, the merge is simply the concatenation of
the two edit lists: applying first’s edits reaches B1, then applying second’s edits
(already expressed against B1) reaches B2. No coordinate remapping is required.
This is used to coalesce buffer deltas that accumulate between consumptions, so a consumer that only reads the latest stored delta still observes every intervening edit.