pub struct ChangeSet { /* private fields */ }Expand description
Edits sorted by position. Overlapping or touching edits are merged on construction, so every position belongs to at most one edit.
Implementations§
Source§impl ChangeSet
impl ChangeSet
Sourcepub fn new(edits: Vec<Edit>) -> Self
pub fn new(edits: Vec<Edit>) -> Self
Sorts and merges edits. When two edits overlap, the merged edit replaces the
union of both ranges with their texts concatenated in position order.
pub fn edits(&self) -> &[Edit]
pub fn is_empty(&self) -> bool
Sourcepub fn apply(&self, rope: &mut Rope) -> ChangeSet
pub fn apply(&self, rope: &mut Rope) -> ChangeSet
Applies the change set and returns its inverse.
Sourcepub fn map(&self, pos: usize, assoc: Assoc) -> usize
pub fn map(&self, pos: usize, assoc: Assoc) -> usize
Maps a char offset from before the change to after it.
A position inside a replaced range moves to its start (Before) or end (After).
Sourcepub fn describe(&self, rope: &Rope) -> Vec<EditEvent>
pub fn describe(&self, rope: &Rope) -> Vec<EditEvent>
Describes the edits for incremental consumers (LSP didChange, tree-sitter Tree::edit).
rope must be the document before the change. Events come last edit first, so each
event’s coordinates stay valid after the events before it have been applied.
Trait Implementations§
impl Eq for ChangeSet
impl StructuralPartialEq for ChangeSet
Auto Trait Implementations§
impl Forget for ChangeSet
impl Freeze for ChangeSet
impl Move for ChangeSet
impl RefUnwindSafe for ChangeSet
impl Send for ChangeSet
impl Sync for ChangeSet
impl Unpin for ChangeSet
impl UnsafeUnpin for ChangeSet
impl UnwindSafe for ChangeSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more