mirror of
https://github.com/loro-dev/loro.git
synced 2025-02-06 04:19:34 +00:00
fix: slice issue
This commit is contained in:
parent
037093f6bd
commit
ec07825c4f
4 changed files with 14 additions and 16 deletions
|
@ -186,7 +186,6 @@ impl Container for TextContainer {
|
|||
format!("{:?}", self.head).red(),
|
||||
format!("{:?}", latest_head).red(),
|
||||
);
|
||||
dbg!(&self.tracker);
|
||||
for effect in self.tracker.iter_effects(path.right) {
|
||||
debug_log!("EFFECT: {:?}", &effect);
|
||||
match effect {
|
||||
|
|
|
@ -318,20 +318,19 @@ mod test {
|
|||
2,
|
||||
vec![
|
||||
Ins {
|
||||
content: "a".into(),
|
||||
pos: 14072811359363267,
|
||||
content: "12345".into(),
|
||||
pos: 6447834,
|
||||
site: 0,
|
||||
},
|
||||
Sync { from: 186, to: 187 },
|
||||
Ins {
|
||||
content: "b".into(),
|
||||
pos: 1374464008290728467,
|
||||
site: 19,
|
||||
content: "x".into(),
|
||||
pos: 17753860855744831232,
|
||||
site: 115,
|
||||
},
|
||||
Ins {
|
||||
content: "c".into(),
|
||||
pos: 3175903134871683258,
|
||||
site: 186,
|
||||
Del {
|
||||
pos: 18335269204214833762,
|
||||
len: 52354349510255359,
|
||||
site: 0,
|
||||
},
|
||||
],
|
||||
)
|
||||
|
|
|
@ -25,13 +25,13 @@ macro_rules! fx_map {
|
|||
macro_rules! debug_log {
|
||||
() => {
|
||||
if cfg!(test) {
|
||||
$crate::print!("\n")
|
||||
// $crate::print!("\n")
|
||||
}
|
||||
};
|
||||
($($arg:tt)*) => {{
|
||||
if cfg!(test) {
|
||||
print!("{}:{}\t", file!(), line!());
|
||||
println!($($arg)*);
|
||||
// print!("{}:{}\t", file!(), line!());
|
||||
// println!($($arg)*);
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
|
|
@ -107,8 +107,8 @@ impl<T: HasLength + Sliceable, A: Array<Item = T>> Sliceable for SmallVec<A> {
|
|||
for item in self.iter() {
|
||||
if index < to && from < index + item.content_len() {
|
||||
let start = if index < from { from - index } else { 0 };
|
||||
let len = item.content_len().min(to - index);
|
||||
ans.push(item.slice(start, from + len));
|
||||
let len = (item.content_len() - start).min(to - index);
|
||||
ans.push(item.slice(start, start + len));
|
||||
}
|
||||
|
||||
index += item.content_len();
|
||||
|
|
Loading…
Reference in a new issue