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 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-07-20 18:04:41 +03:00
1 parent bda79c5967
commit fd33810057
1 file changed
+10 -3
+10 -3
View File
@@ -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<String> = 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<TruckEntity> {
// 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()