fix: a size worked out from a bare diameter keeps its unit when the design's units change (#716) (#779)

A size typed as a bare diameter now keeps the design's length unit, so it no longer changes when the design's units change. Fixes #716.
This commit is contained in:
semmelrinde authored and GitHub committed 2026-10-13 12:35:25 -04:00
1 parent 8cdefd4cd5
commit dfa9e094cd
7 files changed
+309 -14

No files matched your search

+1 -1
View File
@@ -466,7 +466,7 @@ impl Document {
/// in (feature inputs are stored in mm otherwise). Anything else is returned unchanged.
pub fn with_design_unit(&self, e: &str, kind: Kind) -> String {
let u = self.units.trim();
let bare = expr::is_literal(e) && e.trim().trim_start_matches(['-', '+']).trim().parse::<f64>().is_ok();
let bare = expr::is_bare_number(e);
if kind == Kind::Length && bare && !u.is_empty() && u != "mm" && expr::unit_info(u).is_some_and(|(k, _)| k == Kind::Length) {
format!("{} {u}", e.trim())
} else {