Skip to content

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

LRC-LIB-SMARTCOLL: Any Searchable Text covers state, alt text, people, copy name

Nathaniel Ledford5d86976b821d
diff --git a/crates/catalog/src/rules.rs b/crates/catalog/src/rules.rs
index 6e97fc667..8975ce3b9 100644
--- a/crates/catalog/src/rules.rs
+++ b/crates/catalog/src/rules.rs
@@ -398,9 +398,13 @@ impl Rule {
&m.lens,
&m.location,
&m.city,
+ &m.state,
&m.country,
+ &m.alt_text,
&p.format,
&m.keywords.join(" "),
+ &p.people().join(" "),
+ p.copy_name.as_deref().unwrap_or(""),
]
.join(" ");
text(&all)
@@ -797,6 +801,30 @@ mod tests {
);
}
+ /// Any Searchable Text also finds the state / province, the alt text, a person on a face and
+ /// a virtual copy's name, as it already finds the city and country.
+ #[test]
+ fn any_searchable_text_covers_new_fields() {
+ let cat = Catalog::new();
+ let mut p = photo(1);
+ let m = |p: &Photo, value: &str| rs(json!({"rules": [{"field": "text", "op": "contains", "value": value}]})).matches(p, &cat);
+ for word in ["oregon", "kite", "ana", "bluish"] {
+ assert!(!m(&p, word), "{word}");
+ }
+ p.meta.state = "Oregon".into();
+ p.meta.alt_text = "A kite".into();
+ p.meta.regions = vec![lightcraft_meta::Region {
+ rect: lightcraft_meta::Rect { x0: 0.4, y0: 0.4, x1: 0.6, y1: 0.6 },
+ kind: lightcraft_meta::RegionKind::Face,
+ name: Some("Ana".into()),
+ description: None,
+ }];
+ p.copy_name = Some("Bluish".into());
+ for word in ["oregon", "kite", "ana", "bluish"] {
+ assert!(m(&p, word), "{word}");
+ }
+ }
+
/// The field menu shows every rule field once: at the top level or in exactly one group,
/// and [`FIELDS`] lists them in menu order.
#[test]