Kelvin presets: match multiword makes in the catalog's joined camera lookup

covers_camera tried only the first-space split, so NIKON CORPORATION NIKON Z5_2
stayed on the relative scale in the catalog and editor. Try every split, as
spectral::find_camera does.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Andrew Frahn
2026-10-20 10:04:25 +11:00
co-authored by Claude Sonnet 5.5
parent 522e29919d
commit d8f1b30bcc
2 changed files with 5 additions and 4 deletions
+1
View File
@@ -653,6 +653,7 @@ mod edited_tests {
("SONY ILCE-1", "ARW", true),
("", "ARW", true),
("SONY ILCE-7M3", "DNG", false),
("NIKON CORPORATION NIKON Z5_2", "NEF", false),
] {
let mut p = Photo::new(PhotoId(1), Source::Demo { scene: 0 }, "a.raw", format, 10, 10, "2026-10-01T00:00:00");
p.kind = MediaKind::Raw;
+4 -4
View File
@@ -55,10 +55,9 @@ pub fn covers(make: Option<&str>, model: &str) -> bool {
/// [`covers`] for make and model joined by a space, as the catalog keeps them (`"SONY ILCA-99M2"`).
pub fn covers_camera(camera: &str) -> bool {
match camera.split_once(char::is_whitespace) {
Some((make, model)) => covers(Some(make), model),
None => covers(None, camera),
}
let words: Vec<&str> = camera.split_whitespace().collect();
// the make can be several words ("NIKON CORPORATION"), so try every split, as `spectral::find_camera` does
(1..words.len()).any(|i| covers(Some(&words[..i].join(" ")), &words[i..].join(" "))) || covers(None, camera)
}
/// A camera's multipliers at five stated temperatures, ascending, green = 1.
@@ -220,6 +219,7 @@ mod tests {
#[test]
fn covered_models() {
assert!(covers_camera("NIKON CORPORATION NIKON Z5_2") && covers_camera("NIKON Z5_2") && !covers_camera("NIKON CORPORATION NIKON Z6"));
for c in ["SONY ILCA-99M2", "SONY DSC-RX10", "SONY ILCA-77M2", "SONY SLT-A33", "ILCA-99M2", "Sony ilca-99m2"] {
assert!(covers_camera(c), "{c}");
}