mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-26 02:59:17 -06:00
LRC-LIB-KEYWORDS: a set keyword toggles off whatever its case
`keyword.toggleFromSet` checked whether every target photo had the keyword by ASCII case, while the set's buttons and the rest of the keyword code match any letter's case: with "ÄRZTE" and "ärzte" on the photos the button showed on, but ⌥N added the keyword (a no-op) instead of taking it off, so it could never be toggled off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
69c91013e0
commit
f2f164f012
@@ -184,7 +184,11 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
};
|
||||
let ids = s.targets(p);
|
||||
let all = !ids.is_empty()
|
||||
&& ids.iter().all(|id| s.catalog.photo(*id).is_some_and(|ph| ph.meta.keywords.iter().any(|x| x.eq_ignore_ascii_case(&k))));
|
||||
&& ids.iter().all(|id| {
|
||||
s.catalog
|
||||
.photo(*id)
|
||||
.is_some_and(|ph| ph.meta.keywords.iter().any(|x| lightcraft_catalog::keywords::same(&clean(x), &clean(&k))))
|
||||
});
|
||||
let ids: Vec<u64> = ids.iter().map(|i| i.0).collect();
|
||||
let key = if all { "removeKeywords" } else { "addKeywords" };
|
||||
// applying from Recent Keywords mustn't reshuffle the numbers under the keys
|
||||
|
||||
@@ -170,3 +170,16 @@ fn keyword_actions_count_the_photos_they_change() {
|
||||
assert_eq!(s.execute("keyword.rename", &json!({"from": "Marriages", "to": "Weddings"})).unwrap()["changed"], 1);
|
||||
assert_eq!(s.execute("keyword.delete", &json!({"keyword": "weddings"})).unwrap()["changed"], 1);
|
||||
}
|
||||
|
||||
/// ⌥1–⌥9 take a set's keyword off the selected photos when they all have it, whatever the case of
|
||||
/// any of its letters (the set has "ärzte", the photos "ÄRZTE" and "ärzte").
|
||||
#[test]
|
||||
fn a_set_keyword_toggles_whatever_its_case() {
|
||||
let mut s = Session::with_demo();
|
||||
let ids: Vec<u64> = s.visible_cloned().iter().take(2).map(|p| p.0).collect();
|
||||
s.execute("photo.setMeta", &json!({"ids": [ids[0]], "keywords": ["ÄRZTE"]})).unwrap();
|
||||
s.execute("photo.setMeta", &json!({"ids": [ids[1]], "keywords": ["ärzte"]})).unwrap();
|
||||
s.execute("keyword.saveSet", &json!({"name": "Clinic", "keywords": ["ärzte"]})).unwrap();
|
||||
s.execute("keyword.toggleFromSet", &json!({"index": 1, "ids": ids})).unwrap();
|
||||
assert!(ids.iter().all(|id| keywords_of(&s, *id).is_empty()), "taken off both");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user