fix: try to put origin right to an un deleted elem

This commit is contained in:
Zixuan Chen 2022-10-13 17:51:52 +08:00
parent 7c032b6321
commit 0509db416b

View file

@ -104,18 +104,24 @@ impl ContentMap {
} }
let next = if prev.is_some() { let next = if prev.is_some() {
let next_cursor = cursor.next_elem_start(); let mut next_cursor = cursor.next_elem_start();
if let Some(next_inner) = next_cursor { let mut ans = None;
let mut cursor = next_inner.unwrap(); while let Some(next_inner) = next_cursor {
cursor.offset = 0; if next_inner.as_ref().status.is_activated() {
cursor.pos = Position::Start; let mut cursor = next_inner.unwrap();
Some(CursorWithId { cursor.offset = 0;
id: next_inner.as_ref().id, cursor.pos = Position::Start;
cursor, ans = Some(CursorWithId {
}) id: next_inner.as_ref().id,
} else { cursor,
None });
break;
}
next_cursor = next_inner.next_elem_start();
} }
ans
} else { } else {
// if prev is none, next should be the first element in the tree // if prev is none, next should be the first element in the tree
let mut prev = cursor.prev_elem(); let mut prev = cursor.prev_elem();