huskies: merge 874

This commit is contained in:
dave
2026-04-29 16:54:50 +00:00
parent deffcdc326
commit c84786364a
2 changed files with 54 additions and 1 deletions
+6 -1
View File
@@ -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")
})?;