From e45064f8a82f5f11cb03d8a8e1a518d268f7cb75 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Sun, 21 Jun 2026 02:12:58 +0300 Subject: [PATCH] fix(clipboard): carry block-internal layers and refresh the layer panel Cross-drawing paste recreated layers/linetypes/styles only for the top-level selection, so objects inside a pasted block landed on layers the target drawing didn't have. Scan the entities inside captured block definitions for their dependencies too. Also refresh the layer panel after a paste so the brought-in layers show in the manager and the dropdown. Co-Authored-By: Claude Opus 4.8 --- src/app/cmd_result.rs | 3 +++ src/app/mod.rs | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/cmd_result.rs b/src/app/cmd_result.rs index 65ec3923b..d27d118fd 100644 --- a/src/app/cmd_result.rs +++ b/src/app/cmd_result.rs @@ -623,6 +623,9 @@ impl OpenCADStudio { // render instead of staying invisible. (#135) self.tabs[i].scene.populate_meshes_from_document(); self.tabs[i].dirty = true; + // Surface any layers the paste brought in (cross-drawing) + // in the layer manager and the layer dropdown. + self.refresh_layer_panel(); self.refresh_properties(); self.command_line .push_info(&format!("{count} object(s) pasted.")); diff --git a/src/app/mod.rs b/src/app/mod.rs index ee106c96f..e84b7c78b 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -684,7 +684,12 @@ impl ClipboardDeps { || n.eq_ignore_ascii_case("ByLayer") || n.eq_ignore_ascii_case("ByBlock") }; - for e in entities { + // Scan the copied entities AND the entities inside every captured + // block definition, so a block-internal object's layer / linetype / + // style is recreated too — not just the top-level selection's. + let blocks = Self::capture_blocks(doc, entities); + let block_entities = blocks.iter().flat_map(|d| d.entities.iter()); + for e in entities.iter().chain(block_entities) { let c = e.common(); if !c.layer.is_empty() { layers.insert(c.layer.clone()); @@ -719,7 +724,7 @@ impl ClipboardDeps { linetypes: ltypes.iter().filter_map(|n| doc.line_types.get(n).cloned()).collect(), text_styles: tstyles.iter().filter_map(|n| doc.text_styles.get(n).cloned()).collect(), dim_styles: dstyles.iter().filter_map(|n| doc.dim_styles.get(n).cloned()).collect(), - blocks: Self::capture_blocks(doc, entities), + blocks, } }