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 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-13 08:04:13 +03:00
1 parent 925c91ccfa
commit 3840630ab4
2 files changed
+22 -6

No files matched your search

+10 -1
View File
@@ -1386,8 +1386,17 @@ impl OpenCADStudio {
.map(|e| (h, e))
})
.collect();
let initial_edges: Vec<codec::Handle> = 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));
}
+12 -5
View File
@@ -3358,21 +3358,28 @@ pub struct ExtendCommand {
impl ExtendCommand {
pub fn new(all_entities: Vec<EntityType>) -> 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<EntityType>, initial_edges: Vec<Handle>) -> Self {
let all_entities: Vec<EntityType> = 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) {