mirror of
https://github.com/loro-dev/loro.git
synced 2025-01-22 12:57:20 +00:00
fix: get is span should consider unapplied status
This commit is contained in:
parent
6da6cd2915
commit
9080e68c89
5 changed files with 26 additions and 14 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/target
|
||||
*.log
|
||||
flamegraph.svg
|
||||
target
|
||||
|
|
1
crates/loro-core/fuzz/.gitignore
vendored
1
crates/loro-core/fuzz/.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
target
|
||||
corpus
|
||||
artifacts
|
||||
coverage
|
||||
|
|
|
@ -18,7 +18,7 @@ crev:
|
|||
cargo crev crate check
|
||||
|
||||
fuzz:
|
||||
cargo fuzz run yata -- -max_total_time=300 -max_len=1000 -jobs=2
|
||||
cargo fuzz run yata -- -max_total_time=300 -max_len=4000 -jobs=2
|
||||
|
||||
flame:
|
||||
cargo flamegraph --example test --features=fuzzing --root
|
||||
|
|
|
@ -7,7 +7,7 @@ use rle::{
|
|||
|
||||
use crate::{id::ID, span::IdSpan};
|
||||
|
||||
use super::y_span::{StatusChange, YSpan, YSpanTreeTrait};
|
||||
use super::y_span::{Status, StatusChange, YSpan, YSpanTreeTrait};
|
||||
|
||||
/// It stores all the [YSpan] data, including the deleted/undo ones
|
||||
///
|
||||
|
@ -80,22 +80,33 @@ impl ContentMap {
|
|||
}
|
||||
}
|
||||
|
||||
let next = if prev.is_some() {
|
||||
let next_cursor = cursor.next_elem_start();
|
||||
if prev.is_some() {
|
||||
let mut next_cursor = cursor.next_elem_start();
|
||||
let mut ans = None;
|
||||
if let Some(next_inner) = next_cursor {
|
||||
let mut cursor = next_inner.unwrap();
|
||||
cursor.offset = 0;
|
||||
cursor.pos = Position::Start;
|
||||
ans = Some(next_inner.as_ref().id);
|
||||
while let Some(next_inner) = next_cursor {
|
||||
if next_inner.as_ref().status.unapplied {
|
||||
let mut cursor = next_inner.unwrap();
|
||||
cursor.offset = 0;
|
||||
cursor.pos = Position::Start;
|
||||
ans = Some(next_inner.as_ref().id);
|
||||
break;
|
||||
}
|
||||
|
||||
next_cursor = next_inner.next_elem_start();
|
||||
}
|
||||
|
||||
ans
|
||||
(prev, ans)
|
||||
} else {
|
||||
Some(cursor.as_ref().id)
|
||||
};
|
||||
while cursor.as_ref().status.unapplied {
|
||||
if let Some(next) = cursor.next_elem_start() {
|
||||
cursor = next;
|
||||
} else {
|
||||
return (prev, None);
|
||||
}
|
||||
}
|
||||
|
||||
(prev, next)
|
||||
(prev, Some(cursor.as_ref().id))
|
||||
}
|
||||
} else {
|
||||
(None, None)
|
||||
}
|
||||
|
|
|
@ -72,7 +72,6 @@ impl YSpan {
|
|||
|
||||
#[inline]
|
||||
pub fn can_be_origin(&self) -> bool {
|
||||
debug_assert!(self.len > 0);
|
||||
self.status.is_activated()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue