Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Enable Filters: a folder in the filter follows a move with filters on too (follow-up to #2709)

Marco Arnulfob04e0de4ac35
diff --git a/crates/engine/src/cmd/browse.rs b/crates/engine/src/cmd/browse.rs
index 8b9acf65f..a5896c7e9 100644
--- a/crates/engine/src/cmd/browse.rs
+++ b/crates/engine/src/cmd/browse.rs
@@ -482,6 +482,7 @@ pub(crate) fn follow_folder(s: &mut Session, from: &str, to: &str) {
// a library folder chosen at or below it follows too, as a source or as a filter
follow_library_folder(&mut s.library_folder, from, to);
follow_library_folder(&mut s.filter.library_folder, from, to);
+ follow_library_folder(&mut s.filter.folder, from, to);
if let Some(f) = s.shelved_filter.as_mut() {
follow_library_folder(&mut f.library_folder, from, to);
follow_library_folder(&mut f.folder, from, to);
diff --git a/crates/engine/src/tests_shelved_folder.rs b/crates/engine/src/tests_shelved_folder.rs
index a68b329cf..c29453df6 100644
--- a/crates/engine/src/tests_shelved_folder.rs
+++ b/crates/engine/src/tests_shelved_folder.rs
@@ -52,6 +52,20 @@ fn a_folder_in_the_filter_put_aside_follows_a_move() {
assert_eq!(s.visible().len(), 1, "the moved photo, as before the move");
}
+#[test]
+fn a_folder_in_the_filter_follows_a_move_with_filters_on() {
+ let dir = Scratch::new("live");
+ let (trip, archive) = (dir.path("trip"), dir.path("archive"));
+ let mut s = Session::new();
+ add(&mut s, &format!("{trip}/a.jpg"), 0);
+ add(&mut s, &dir.path("elsewhere.jpg"), 0);
+ s.execute("library.filter", &json!({"folder": trip})).unwrap();
+ assert_eq!(s.visible().len(), 1, "the filter hides a photo, or a stale folder would look alike");
+ s.execute("folder.move", &json!({"path": trip, "into": archive})).unwrap();
+ assert_eq!(s.filter.folder.as_deref(), Some(dir.path("archive/trip").as_str()), "the folder where it went");
+ assert_eq!(s.visible().len(), 1, "the moved photo, as before the move");
+}
+
#[test]
fn moving_the_browsed_folder_while_off_brings_back_the_filter_put_aside() {
let dir = Scratch::new("browse");