fix(undo): grip-drag history entry + mid-command Ctrl+Z steps (#332)
Grip drags mutated the document without ever pushing history — dragging a polyline vertex (or any grip) could not be undone. The release-commit now swaps the pre-drag backup in, snapshots that PRE state as a "GRIP" entry, swaps the dragged result back and clears the redo stack; the Esc-cancel path is unchanged and a no-move engaging click records nothing. Ctrl+Z during a drawing command steps the command instead of the document undo swallowing the in-progress object (which also killed the active command): new CadCommand::on_undo_step hook, consulted before undo_active_tab. PLINE pops its last vertex (shared with the U option), LINE reverts the last committed segment and keeps drawing from the previous point (rides its existing U/UndoDocument path), and ARC Continue reverts the last arc and resumes from the prior anchor with the correct tangent via a new anchor history. With nothing placed yet each falls through to the document undo. Also drops the two warnings the #336 work left behind (unused Entity import, dead Snapper::override_active). Closes #332 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
9b40881ab1
commit
9b28170d4b
8 changed files with 109 additions and 34 deletions
|
|
@ -3709,6 +3709,17 @@ impl OpenCADStudio {
|
|||
Message::PspaceCommand => Task::done(Message::ExitViewport),
|
||||
|
||||
Message::Undo => {
|
||||
// Mid-command Ctrl+Z: a drawing command steps itself back
|
||||
// (PLINE pops the last vertex) instead of the document undo
|
||||
// swallowing the whole in-progress object.
|
||||
let i = self.active_tab;
|
||||
let step = self.tabs[i]
|
||||
.active_cmd
|
||||
.as_mut()
|
||||
.and_then(|c| c.on_undo_step());
|
||||
if let Some(r) = step {
|
||||
return self.apply_cmd_result(r);
|
||||
}
|
||||
self.undo_active_tab();
|
||||
Task::none()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue