huskies: merge 874
This commit is contained in:
@@ -249,8 +249,13 @@ pub fn evict_item(story_id: &str) -> Result<(), String> {
|
||||
|
||||
// Resolve the item's OpId before the closure (the closure will mutably
|
||||
// borrow `state`, so we can't access `state.crdt.doc.items` from inside).
|
||||
//
|
||||
// `rebuild_index` uses `items.iter()` which skips the invisible ROOT
|
||||
// sentinel, so `idx` is a 0-based visible-item position. `id_at` counts
|
||||
// ALL non-deleted ops including the sentinel at position 0, so we must
|
||||
// add 1 to translate from visible-item position to `id_at` position.
|
||||
let item_id =
|
||||
state.crdt.doc.items.id_at(idx).ok_or_else(|| {
|
||||
state.crdt.doc.items.id_at(idx + 1).ok_or_else(|| {
|
||||
format!("Item index {idx} for '{story_id}' did not resolve to an OpId")
|
||||
})?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user