PEDIT: pre-selected line or arc asks to turn it into a polyline (#745) (#796)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Valentin Klein 2026-10-13 10:37:01 +02:00 committed by GitHub
parent 8073453d86
commit f26588a357
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 4 deletions

View File

@ -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)

View File

@ -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(_)));
}