mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 17:37:14 +00:00
Fix File Info showing 1/1 s for exposures just under one second
Found while testing crates/engine/src/file_cmds.rs:768 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
03d0c7e3b3
commit
ff2db1b83b
2 files changed
+8
-1
No files matched your search
@@ -765,7 +765,7 @@ fn exposure_text(t: f64) -> Option<String> {
|
||||
return None;
|
||||
}
|
||||
let r = 1.0 / t;
|
||||
if t < 1.0 && (r - r.round()).abs() <= r * 0.01 {
|
||||
if t < 1.0 && r.round() > 1.0 && (r - r.round()).abs() <= r * 0.01 {
|
||||
return Some(format!("1/{} s", r.round()));
|
||||
}
|
||||
Some(format!("{} s", short_num(t, if t < 1.0 { 2 } else { 1 })))
|
||||
|
||||
@@ -1354,3 +1354,10 @@ fn batch_naming_rejects_outputs_that_replace_inputs_before_processing() {
|
||||
assert_eq!(std::fs::read(&first).unwrap(), before[0]);
|
||||
assert_eq!(std::fs::read(&second).unwrap(), before[1]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exposure_text_near_one_second_is_not_one_over_one() {
|
||||
assert_eq!(exposure_text(0.996).as_deref(), Some("1 s"));
|
||||
assert_eq!(exposure_text(0.99).as_deref(), Some("0.99 s"));
|
||||
assert_eq!(exposure_text(1.0 / 250.0).as_deref(), Some("1/250 s"));
|
||||
}
|
||||
Reference in new issue
Block a user