From 3840630ab4dc10374aeae0677186e4fd927808b8 Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Tue, 13 Oct 2026 08:04:13 +0300 Subject: [PATCH] fix(extend): use preselected objects as boundary edges TRIM already takes objects selected before the command as cutting edges; EXTEND ignored them and extended to the nearest object in the path. It now takes them as boundary edges the same way. Fixes #1732 Co-Authored-By: Claude Opus 5.5 --- src/app/commands/dim.rs | 11 ++++++++++- src/modules/draw/modify/trim.rs | 17 ++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/app/commands/dim.rs b/src/app/commands/dim.rs index 112981216..fe7b2423a 100644 --- a/src/app/commands/dim.rs +++ b/src/app/commands/dim.rs @@ -1386,8 +1386,17 @@ impl OpenCADStudio { .map(|e| (h, e)) }) .collect(); + let initial_edges: Vec = self.tabs[i] + .scene + .selected_entities() + .into_iter() + .filter_map(|(handle, entity)| { + crate::modules::draw::modify::trim::is_trim_boundary_entity(&entity) + .then_some(handle) + }) + .collect(); let all_entities: Vec<_> = entities.into_iter().map(|(_, e)| e).collect(); - let new_cmd = ExtendCommand::new(all_entities); + let new_cmd = ExtendCommand::with_boundary_edges(all_entities, initial_edges); self.command_line.push_info(&new_cmd.prompt()); self.tabs[i].active_cmd = Some(Box::new(new_cmd)); } diff --git a/src/modules/draw/modify/trim.rs b/src/modules/draw/modify/trim.rs index 8e002a9d7..8c9faaeba 100644 --- a/src/modules/draw/modify/trim.rs +++ b/src/modules/draw/modify/trim.rs @@ -3358,21 +3358,28 @@ pub struct ExtendCommand { impl ExtendCommand { pub fn new(all_entities: Vec) -> Self { + Self::with_boundary_edges(all_entities, Vec::new()) + } + + /// Objects selected before the command are its boundary edges, as TRIM + /// takes them as cutting edges. + pub fn with_boundary_edges(all_entities: Vec, initial_edges: Vec) -> Self { let all_entities: Vec = all_entities .iter() .map(entity_with_lwpolyline_world_xy) .collect(); let entity_index = ModifyEntityIndex::build(&all_entities); - let geos = build_geos(&all_entities); - Self { + let mut cmd = Self { all_entities, entity_index, - geos, + geos: Vec::new(), mode: TrimMode::Pick, - edge_set: Vec::new(), + edge_set: initial_edges, implied_edges: false, shift: false, - } + }; + cmd.rebuild_geos(); + cmd } fn rebuild_geos(&mut self) {