T17 review fixes: hidden numbers draw, empty edits and read-only commands change nothing, hints stay in a ghost-cut row, the newest cursor leads, a composition undoes in one step, call keys carry their place, references count matches, trailing-space hits and **/ globs, name-only switcher marks, pin and remove stay on their button, settings show their places; decimals moves to typography::format

This commit is contained in:
ZacharyZhang-NY committed 2026-09-26 01:07:37 -04:00
1 parent 5545ce6458
commit 8ea952c6dc
20 files changed
+383 -85

No files matched your search

+35
View File
@@ -136,6 +136,21 @@ pub fn duration(seconds: u64, style: DurationStyle) -> String {
}
}
/// Digits kept past a step's first; float noise sits near the sixteenth.
const DIGITS: usize = 6;
/// Places after the point that show every multiple of `step` exactly: none for whole steps, four for 0.0025.
pub(crate) fn decimals(step: f64) -> usize {
assert!(
step.is_finite() && step > 0.0,
"a step is positive, not {step}"
);
let leading = (-step.log10().floor()).max(0.0) as usize;
let text = format!("{step:.*}", leading + DIGITS);
let fraction = text.split_once('.').map_or("", |(_, fraction)| fraction);
fraction.trim_end_matches('0').len()
}
/// "1 file", "12,345 files".
pub fn plural(count: u64, one: &str, other: &str) -> String {
let word = if count == 1 { one } else { other };
@@ -189,6 +204,26 @@ pub fn datetime(at: Timestamp, zone: &TimeZone, pattern: &str) -> Result<String,
mod tests {
use super::*;
#[test]
fn steps_read_to_the_places_they_need() {
assert_eq!(
(
decimals(10.0),
decimals(0.5),
decimals(0.05),
decimals(0.001)
),
(0, 1, 2, 3)
);
assert_eq!(decimals(0.0025), 4, "a quarter of a cent needs four places");
assert_eq!(
decimals(110.2 - 110.0),
1,
"float noise from a difference drops away"
);
assert_eq!(decimals(1e-11), 11, "a tiny step keeps its places");
}
#[test]
fn number_groups_and_rounds() {
assert_eq!(number(1234567.891, 2, Separators::EN), "1,234,567.89");