diff --git a/crates/loro-core/src/container/text/tracker.rs b/crates/loro-core/src/container/text/tracker.rs index 07d3c858..993f4d49 100644 --- a/crates/loro-core/src/container/text/tracker.rs +++ b/crates/loro-core/src/container/text/tracker.rs @@ -77,6 +77,11 @@ impl Tracker { } } + /// check whether id_to_cursor correctly reflect the status of the content + fn check_consistency(&self) { + todo!() + } + fn turn_on(&mut self, _id: IdSpan) {} fn turn_off(&mut self, _id: IdSpan) {} fn checkout(&mut self, _vv: VersionVector) {} diff --git a/crates/loro-core/src/container/text/tracker/y_span.rs b/crates/loro-core/src/container/text/tracker/y_span.rs index b1140612..337efaa8 100644 --- a/crates/loro-core/src/container/text/tracker/y_span.rs +++ b/crates/loro-core/src/container/text/tracker/y_span.rs @@ -62,6 +62,7 @@ pub enum StatusChange { pub(super) type YSpanTreeTrait = CumulateTreeTrait; impl YSpan { + /// this is the last id of the span, which is **included** by self #[inline] pub fn last_id(&self) -> ID { self.id.inc(self.len as i32 - 1) @@ -77,7 +78,7 @@ impl YSpan { pub fn contain_id(&self, id: ID) -> bool { self.id.client_id == id.client_id && self.id.counter <= id.counter - && self.last_id().counter > id.counter + && self.last_id().counter >= id.counter } } diff --git a/crates/rle/src/rle_tree/cursor.rs b/crates/rle/src/rle_tree/cursor.rs index 573924d5..157741c3 100644 --- a/crates/rle/src/rle_tree/cursor.rs +++ b/crates/rle/src/rle_tree/cursor.rs @@ -5,7 +5,7 @@ use crate::{Rle, RleTreeTrait}; use super::{node::LeafNode, tree_trait::Position}; /// when len > 0, it acts as a selection. When iterating the tree, the len should be the size of the element. -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, Debug)] pub struct UnsafeCursor<'tree, 'bump, T: Rle, A: RleTreeTrait> { pub leaf: NonNull>, pub index: usize, @@ -32,11 +32,13 @@ impl<'tree, 'bump, T: Rle, A: RleTreeTrait> Clone for UnsafeCursor<'tree, 'bu impl<'tree, 'bump: 'tree, T: Rle, A: RleTreeTrait> Copy for UnsafeCursor<'tree, 'bump, T, A> {} #[repr(transparent)] +#[derive(Debug)] pub struct SafeCursor<'tree, 'bump, T: Rle, A: RleTreeTrait>( pub(crate) UnsafeCursor<'tree, 'bump, T, A>, ); #[repr(transparent)] +#[derive(Debug)] pub struct SafeCursorMut<'tree, 'bump, T: Rle, A: RleTreeTrait>( pub(crate) UnsafeCursor<'tree, 'bump, T, A>, ); diff --git a/crates/rle/src/rle_tree/iter.rs b/crates/rle/src/rle_tree/iter.rs index a759658b..9aebf326 100644 --- a/crates/rle/src/rle_tree/iter.rs +++ b/crates/rle/src/rle_tree/iter.rs @@ -137,6 +137,7 @@ impl<'tree, 'bump: 'tree, T: Rle, A: RleTreeTrait> Iterator for Iter<'tree, ' end.offset - cursor.offset, ) }); + cursor.offset = end.offset; self.cursor = None; return ans; }