From fd33810057d1c202583cd0e441e7e9a7784ca1da Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Mon, 20 Jul 2026 18:04:41 +0300 Subject: [PATCH] fix(attribute): blank INSERT attribute renders nothing, not "[]" An INSERT attribute left with an empty value drew a "[]" placeholder: the SingleLine tessellation fell back to `[value]` whenever every line was empty, but that branch only fires once the value is already empty, so it always produced bare brackets (and never carried the tag it was meant to preview). On a heavily scaled block instance the unscaled brackets ballooned across the sheet. Render nothing for an empty value instead, matching AutoCAD, where a blank attribute shows no text. An attribute definition previews its tag as a non-empty value, so it never reached this branch and is unaffected. Co-Authored-By: Claude Opus 4.8 --- src/entities/attribute.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/entities/attribute.rs b/src/entities/attribute.rs index bb8bded87..75a81cf64 100644 --- a/src/entities/attribute.rs +++ b/src/entities/attribute.rs @@ -235,9 +235,14 @@ fn build_attr_truck(input: AttrTextInputs<'_>, document: &acadrust::CadDocument) .split('\n') .map(|l| l.to_string()) .collect(); - // Tag-style fallback when there is no value (ATTDEF preview style). + // An empty attribute value renders nothing — matching AutoCAD, where a + // filled-in INSERT attribute left blank shows no text. The old `[value]` + // fallback only ever fired when the value was already empty (and never + // carried the tag), so it drew stray "[]" brackets for every blank + // attribute. An ATTDEF preview passes its tag as the value (non-empty), so + // it never reached this branch and is unaffected. let lines: Vec = if plain.iter().all(|l| l.is_empty()) { - vec![format!("[{}]", input.value)] + Vec::new() } else { plain }; @@ -329,8 +334,10 @@ fn build_attr_truck(input: AttrTextInputs<'_>, document: &acadrust::CadDocument) impl TruckConvertible for AttributeDefinition { fn to_truck(&self, document: &acadrust::CadDocument) -> Option { + // An attribute definition previews its tag when it has no default + // value, so the placeholder is visible where a block will prompt for + // input. (Passed as a non-empty value, so it renders as-is.) let display_value = if self.default_value.is_empty() { - // tag-only preview path: build_attr_truck wraps in brackets. self.tag.clone() } else { self.default_value.clone()