mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-29 20:48:33 -06:00
Fix #293: undo and redo show the photo they change
After an undo or redo that changed one photo (its edit, rating, flag, label, metadata or versions), that photo becomes the active one, as in Lightroom Classic, so the change is on screen instead of happening to a photo out of sight. It joins the selection if it isn't in it; steps that touch several photos, albums or files, and photos outside the current view, leave the selection alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01912WaK6Rmew3wxZuPyX7E8
This commit is contained in:
@@ -817,3 +817,29 @@ fn face_job_follows_rotate_right() {
|
||||
let (pw, ph) = ((r.x1 - r.x0) * h, (r.y1 - r.y0) * w);
|
||||
assert!((pw - ph).abs() < 1e-6 * w.max(h), "square in rotated pixels: {pw} × {ph}");
|
||||
}
|
||||
|
||||
/// Undo and redo bring the photo they change on screen (issue #293): after editing one photo and
|
||||
/// moving on, Undo makes it the active photo again; a step that changes several photos leaves the
|
||||
/// selection alone.
|
||||
#[test]
|
||||
fn undo_and_redo_show_the_photo_they_change() {
|
||||
let mut s = demo();
|
||||
let vis = s.visible_cloned();
|
||||
let (a, b) = (vis[0], vis[1]);
|
||||
s.execute("library.select", &json!({"ids": [a.0]})).unwrap();
|
||||
s.execute("develop.set", &json!({"control": "light.exposure", "value": 1.0})).unwrap();
|
||||
s.execute("library.select", &json!({"ids": [b.0]})).unwrap();
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(s.active(), Some(a), "undo shows the photo it changed");
|
||||
assert_eq!(s.selection.ids, vec![a]);
|
||||
s.execute("library.select", &json!({"ids": [b.0]})).unwrap();
|
||||
s.execute("edit.redo", &json!({})).unwrap();
|
||||
assert_eq!(s.active(), Some(a), "so does redo");
|
||||
// rating both selected photos is one step over two photos: undoing it leaves the selection
|
||||
s.execute("library.select", &json!({"ids": [a.0, b.0], "active": b.0})).unwrap();
|
||||
s.execute("photo.rate", &json!({"rating": 3})).unwrap();
|
||||
s.execute("library.select", &json!({"ids": [a.0, b.0], "active": a.0})).unwrap();
|
||||
let before = s.selection.clone();
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(s.selection, before, "a step over several photos keeps the selection");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user