pub struct Operation {
pub content: String,
pub start_position: Position,
pub op_type: OperationType,
}
Expand description
An Operation describe a text edition at a specific start position.
An Operation can be of 2 types: either Insert or Delete, testifying of the fact that we either inserted or deleted the provided text content, starting at a given x/y position.
Fields
content: String
start_position: Position
op_type: OperationType
Implementations
sourceimpl Operation
impl Operation
sourcepub fn end_position(&self, document_rows_length: &[usize]) -> Position
pub fn end_position(&self, document_rows_length: &[usize]) -> Position
Return the position the cursor would be at the end of the Operation.
Examples:
- an insert of “rust” starting at {0, 0} would return an end position of {3, 0}
- an insert of “rust\nrocks” starting at {0, 0} would return an end position of {4, 1}
- a deletion of “tsur” starting at {3, 0} would return an end position of {0, 0}
- a deletion of “skcor\ntsur” starting at {1, 4} would return an end position of {0, 0}
Note: this one took a long time to get right but seems to work. Check unit tests in doubt!
pub fn reversed(&self, document_rows_length: &[usize]) -> Self
Trait Implementations
impl StructuralPartialEq for Operation
Auto Trait Implementations
impl RefUnwindSafe for Operation
impl Send for Operation
impl Sync for Operation
impl Unpin for Operation
impl UnwindSafe for Operation
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more