forked from 1b-agent/opencadstudio-upstream
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:
1 parent
9b40881ab1
commit
9b28170d4b
8 files changed
+109
-34
No files matched your search
@@ -1218,6 +1218,14 @@ pub trait CadCommand: Send {
|
||||
/// during TRIM and trims during EXTEND, #336). Default no-op.
|
||||
fn set_shift(&mut self, _shift: bool) {}
|
||||
|
||||
/// Mid-command Ctrl+Z: a multi-point drawing command can take the undo
|
||||
/// itself (PLINE pops its last vertex) instead of the document undo
|
||||
/// swallowing the whole in-progress object. `None` (default) lets the
|
||||
/// normal document undo run.
|
||||
fn on_undo_step(&mut self) -> Option<CmdResult> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Called when the user left-clicks in the viewport (point pick).
|
||||
fn on_point(&mut self, pt: DVec3) -> CmdResult;
|
||||
|
||||
|
||||
Reference in new issue
Block a user