mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Keep document lifecycle tests consistent with wrapped offsets
This commit is contained in:
1 parent
abb28e4d37
commit
775dc0c070
2 files changed
+3
-3
No files matched your search
@@ -108,7 +108,7 @@ impl Session {
|
||||
let active = self.open_document_order.iter().position(|&open| open == id).ok_or(EngineError::NoDocument)?;
|
||||
// Widen before addition so even extreme signed offsets wrap without overflow.
|
||||
let target = (active as i128 + i128::from(offset)).rem_euclid(self.open_document_order.len() as i128) as usize;
|
||||
let id = &self.open_document_order[target];
|
||||
let id = self.open_document_order.get(target).ok_or(EngineError::NoDocument)?;
|
||||
self.docs.iter().position(|st| st.doc.id == *id).ok_or(EngineError::NoDocument)
|
||||
}
|
||||
|
||||
|
||||
@@ -1756,8 +1756,8 @@ fn document_activate_opening_order_survives_close_and_reopen_with_persisted_ids(
|
||||
}
|
||||
s.execute("file.new", json!({"width": 2, "height": 2, "name": "fresh"})).unwrap();
|
||||
assert_eq!(s.execute("document.activate", json!({"offset": 0})).unwrap(), json!({"document": 0}));
|
||||
assert!(s.execute("document.activate", json!({"offset": -1})).is_err());
|
||||
assert!(s.execute("document.activate", json!({"offset": 1})).is_err());
|
||||
assert_eq!(s.execute("document.activate", json!({"offset": -1})).unwrap(), json!({"document": 0}));
|
||||
assert_eq!(s.execute("document.activate", json!({"offset": 1})).unwrap(), json!({"document": 0}));
|
||||
assert_eq!(s.active().unwrap().doc.name, "fresh");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user