WIP - maintain foldmap with Buffer::edits_since
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
2463077b2d
commit
faba276fdc
11 changed files with 279 additions and 163 deletions
|
@ -1,5 +1,6 @@
|
|||
mod anchor;
|
||||
mod operation_queue;
|
||||
mod patch;
|
||||
mod point;
|
||||
mod point_utf16;
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
|
@ -14,6 +15,7 @@ use anyhow::{anyhow, Result};
|
|||
use clock::ReplicaId;
|
||||
use collections::{HashMap, HashSet};
|
||||
use operation_queue::OperationQueue;
|
||||
pub use patch::Patch;
|
||||
pub use point::*;
|
||||
pub use point_utf16::*;
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
|
@ -24,7 +26,7 @@ pub use selection::*;
|
|||
use std::{
|
||||
cmp::{self, Reverse},
|
||||
iter::Iterator,
|
||||
ops::{self, Deref, Range},
|
||||
ops::{self, Deref, Range, Sub},
|
||||
str,
|
||||
sync::Arc,
|
||||
time::{Duration, Instant},
|
||||
|
@ -307,6 +309,23 @@ pub struct Edit<D> {
|
|||
pub new: Range<D>,
|
||||
}
|
||||
|
||||
impl<D> Edit<D>
|
||||
where
|
||||
D: Sub<D, Output = D> + PartialEq + Copy,
|
||||
{
|
||||
pub fn old_len(&self) -> D {
|
||||
self.old.end - self.old.start
|
||||
}
|
||||
|
||||
pub fn new_len(&self) -> D {
|
||||
self.new.end - self.new.start
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.old.start == self.old.end && self.new.start == self.new.end
|
||||
}
|
||||
}
|
||||
|
||||
impl<D1, D2> Edit<(D1, D2)> {
|
||||
pub fn flatten(self) -> (Edit<D1>, Edit<D2>) {
|
||||
(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue