SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Warnings: quote a long generated name by its start and end (#8673)
semmelrinde89cb651084fa
diff --git a/crates/doc/src/eval.rs b/crates/doc/src/eval.rsindex 5101f1efaf..caffae2f9d 100644--- a/crates/doc/src/eval.rs+++ b/crates/doc/src/eval.rs@@ -4310,7 +4310,8 @@ fn blend_edges_on(mb: &ModelBody, f: &Feature, edges: &[crate::Position], idx: &Some((_, Err(_))) | None => {let mut w = None;let refs: Vec<EdgeRef> = f.edge_refs.get(i).cloned().into_iter().collect();- let skipped = format!("edge `{}` no longer exists and was skipped", stored.map(String::as_str).unwrap_or("?"));+ let skipped =+ format!("edge `{}` no longer exists and was skipped", stored.map_or_else(|| "?".into(), |n| crate::name_lookup::quoted(n)));// The name is gone. A pick on the axis of a round must not fall through to the// tangency seam (#775). A sharp edge that moved still resolves from the point,// which an edit relies on.@@ -4319,7 +4320,7 @@ fn blend_edges_on(mb: &ModelBody, f: &Feature, edges: &[crate::Position], idx: &} else if let Ok(q) = resolve_edges(&mb.body, &[p], &refs, &mut w) {out.extend(q);notes.push(match stored {- Some(n) => format!("edge `{n}` no longer exists; using the edge at the picked point"),+ Some(n) => format!("edge `{}` no longer exists; using the edge at the picked point", crate::name_lookup::quoted(n)),None => "an edge reference without a name was found by its point".into(),});} else {@@ -7215,10 +7216,10 @@ fn face_plane(st: &ModelState, picked: &Plane, at: Vec3, name: Option<&str>) ->let note = if crate::naming::legacy_name(name).is_some() {None} else if !crate::naming::face_has_name(b, f.index, name) {- Some(format!("face `{name}` was split; using the piece nearest the picked point"))+ Some(format!("face `{}` was split; using the piece nearest the picked point", crate::name_lookup::quoted(name)))} else if !crate::naming::face_name_exact(b, f.index) && (f.centroid - at).dot(n).abs() > tol {// Named from geometry and moved off the picked plane: geometry alone decided.- Some(format!("face `{name}` was found by geometry, not exact history; check it"))+ Some(format!("face `{}` was found by geometry, not exact history; check it", crate::name_lookup::quoted(name)))} else {None};diff --git a/crates/doc/src/eval_more.rs b/crates/doc/src/eval_more.rsindex 7a5b7c0f7a..9cc8952423 100644--- a/crates/doc/src/eval_more.rs+++ b/crates/doc/src/eval_more.rs@@ -802,7 +802,10 @@ pub(super) fn sheet_eval(hit.point}Some((n, Err(_))) => {- append_warning(warning, format!("edge `{n}` no longer exists; using the edge at the picked point"));+ append_warning(+ warning,+ format!("edge `{}` no longer exists; using the edge at the picked point", crate::name_lookup::quoted(n)),+ );p.0}None => p.0,diff --git a/crates/doc/src/name_lookup.rs b/crates/doc/src/name_lookup.rsindex 003f17d7be..44f941c223 100644--- a/crates/doc/src/name_lookup.rs+++ b/crates/doc/src/name_lookup.rs@@ -203,11 +203,11 @@ impl FaceHit {/// What a feature says about how it found a face by its stored name `name` (`None`: exactly).pub fn note(&self, name: &str) -> Option<String> {if self.split {- Some(format!("face `{name}` was split; using the piece nearest the picked point"))+ Some(format!("face `{}` was split; using the piece nearest the picked point", quoted(name)))} else if self.merged {Some(format!("face `{name}` was merged into another face; using that face"))} else if !self.verified && !self.on_point && !self.legacy {- Some(format!("face `{name}` was found by geometry, not exact history; check it"))+ Some(format!("face `{}` was found by geometry, not exact history; check it", quoted(name)))} else {None}@@ -243,13 +243,29 @@ impl FaceHit {}}+/// A stored name as a message quotes it: whole up to about 80 characters, else its start and+/// end around an ellipsis. Generated names grow with the history (a split edge's name holds both+/// its faces' names), and a chamfer's warning that quoted fourteen of them in full ran to 122,701+/// characters (#8541).+pub(crate) fn quoted(name: &str) -> String {+ const HEAD: usize = 48;+ const TAIL: usize = 24;+ let n = name.chars().count();+ if n <= HEAD + TAIL + 8 {+ return name.to_string();+ }+ let head: String = name.chars().take(HEAD).collect();+ let tail: String = name.chars().skip(n - TAIL).collect();+ format!("{head}…{tail}")+}+impl EdgeHit {/// What a feature says about how it found an edge by its stored name `name` (`None`: exactly).pub fn note(&self, name: &str) -> Option<String> {if self.split {- Some(format!("edge `{name}` was split; using the piece nearest the picked point"))+ Some(format!("edge `{}` was split; using the piece nearest the picked point", quoted(name)))} else if !self.verified && !self.on_point && !self.legacy {- Some(format!("edge `{name}` was found by geometry, not exact history; check it"))+ Some(format!("edge `{}` was found by geometry, not exact history; check it", quoted(name)))} else {None}diff --git a/crates/doc/src/project.rs b/crates/doc/src/project.rsindex b705ea3262..3887765b79 100644--- a/crates/doc/src/project.rs+++ b/crates/doc/src/project.rs@@ -738,7 +738,7 @@ fn refresh_links_in(*at = p;named_face = Some((body.clone(), index, p));if split {- warn.push(format!("projected face `{name}` was split; using the nearest piece"));+ warn.push(format!("projected face `{}` was split; using the nearest piece", crate::name_lookup::quoted(name)));}} else {sk.set_link_lost(&l.id, true);diff --git a/crates/doc/src/tests.rs b/crates/doc/src/tests.rsindex e3051078a4..0d21d014ed 100644--- a/crates/doc/src/tests.rs+++ b/crates/doc/src/tests.rs@@ -159,6 +159,21 @@ fn results_kept_ahead_outlive_the_cache() {assert!(rel(measure(&m.state().bodies[0].body).unwrap().volume, 30000.0) < 1e-9);}+/// A warning quotes a long generated name by its start and end (#8541: fourteen split edges'+/// full names made one chamfer warning 122,701 characters long); a short name stays whole.+#[test]+fn warnings_quote_long_names_by_their_ends() {+ let face = |i: usize| format!("Extrude{i}.side(Sketch{i}.l{i})·Fillet{i}.blend(Chamfer{i}.cap)");+ let long = (0..40).map(face).collect::<Vec<_>>().join("|");+ let q = crate::name_lookup::quoted(&long);+ assert!(q.chars().count() <= 80, "{q}");+ assert!(q.starts_with("Extrude0.side") && q.ends_with(&long[long.len() - 10..]) && q.contains('…'), "{q}");+ assert_eq!(crate::name_lookup::quoted("Extrude1.side|Box1.top"), "Extrude1.side|Box1.top");+ // Characters, not bytes: a name of non-ASCII characters is cut between characters.+ let wide = "Ü".repeat(200);+ assert_eq!(crate::name_lookup::quoted(&wide).chars().count(), 73);+}+/// A saved model whose feature warning is longer than 65,536 characters is still taken on open/// (#8541): Save writes it, so Open reads it.#[test]