From d8f1b30bcc1af4f216b2a4d01c307f6a2adc1cff Mon Sep 17 00:00:00 2001 From: Andrew Frahn Date: Tue, 20 Oct 2026 10:04:25 +1100 Subject: [PATCH] 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 --- crates/catalog/src/model.rs | 1 + crates/raw/src/kelvin_presets.rs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/catalog/src/model.rs b/crates/catalog/src/model.rs index 6ac3544ee..a3fe36aba 100644 --- a/crates/catalog/src/model.rs +++ b/crates/catalog/src/model.rs @@ -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; diff --git a/crates/raw/src/kelvin_presets.rs b/crates/raw/src/kelvin_presets.rs index 975e578c9..f9465a94c 100644 --- a/crates/raw/src/kelvin_presets.rs +++ b/crates/raw/src/kelvin_presets.rs @@ -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}"); }