diff --git a/crates/engine/src/cmd/modify2.rs b/crates/engine/src/cmd/modify2.rs index 3aa1396..79d74e4 100644 --- a/crates/engine/src/cmd/modify2.rs +++ b/crates/engine/src/cmd/modify2.rs @@ -454,10 +454,17 @@ impl Interactive for PeditM { let sel = s.selection(); if let [h] = sel.as_slice() { let k = curves::entity(s, *h)?.kind; - if matches!(k, EntityKind::LwPolyline(_)) { - self.h = Some(*h); - self.original = self.poly(s).map(|p| p.vertices); - self.phase = PPhase::Main; + match k { + EntityKind::LwPolyline(_) => { + self.h = Some(*h); + self.original = self.poly(s).map(|p| p.vertices); + self.phase = PPhase::Main; + } + EntityKind::Line(_) | EntityKind::Arc(_) => { + self.h = Some(*h); + self.phase = PPhase::Convert; + } + _ => {} } } Ok(Step::Continue) diff --git a/crates/engine/src/cmd/modify2_tests.rs b/crates/engine/src/cmd/modify2_tests.rs index 0b72ece..f28a450 100644 --- a/crates/engine/src/cmd/modify2_tests.rs +++ b/crates/engine/src/cmd/modify2_tests.rs @@ -683,3 +683,27 @@ fn editing_commands_leave_locked_layer_objects_alone() { s.execute("explode", &json!({"handles": [r]})).unwrap(); assert_ne!(model_dump(&s), before); } + +#[test] +fn pedit_preselected_line_asks_to_convert() { + // Yes converts the pre-selected line and continues with the option prompt. + let mut s = Session::new(); + let l = h(&s.execute("line", &json!({"points": [[0, 0], [10, 0]]})).unwrap()); + s.set_selection(vec![Handle::parse_hex(&l).unwrap()]); + s.cmdline("pedit").unwrap(); + assert!(s.running.is_some()); + assert!(matches!(kind(&s, &l), EntityKind::Line(_)), "nothing changes before the answer"); + s.cmdline("y").unwrap(); + assert!(matches!(kind(&s, &l), EntityKind::LwPolyline(_))); + s.cmdline("c").unwrap(); + s.cmdline("").unwrap(); + assert!(s.running.is_none()); + + // No ends the command and leaves the line alone. + let m = h(&s.execute("line", &json!({"points": [[0, 5], [10, 5]]})).unwrap()); + s.set_selection(vec![Handle::parse_hex(&m).unwrap()]); + s.cmdline("pedit").unwrap(); + s.cmdline("n").unwrap(); + assert!(s.running.is_none()); + assert!(matches!(kind(&s, &m), EntityKind::Line(_))); +}