From 17ecd9ff4d0a9d5f67cc75a96e47e625cf11053d Mon Sep 17 00:00:00 2001 From: gianlucafiore Date: Sat, 12 Sep 2026 21:41:34 -0300 Subject: [PATCH] fix(commands): handle Ctrl+Z inside active commands --- src/app/shortcuts.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/app/shortcuts.rs b/src/app/shortcuts.rs index f3116f38c..3682bbbe3 100644 --- a/src/app/shortcuts.rs +++ b/src/app/shortcuts.rs @@ -287,8 +287,30 @@ impl OpenCADStudio { "DYNINPUT" => Message::ToggleDynInput, "SELECTALL" => Message::SelectAllShortcut, "PASTECLIP" => Message::PasteShortcut, + + "UNDO" => { + let i = self.active_tab; + + // Multi-step drawing commands may consume Ctrl+Z themselves. + // For example PLINE/SPLINE should remove only the last entered + // point instead of cancelling the whole in-progress command. + let command_result = self.tabs[i] + .active_cmd + .as_mut() + .and_then(|cmd| cmd.on_undo_step()); + + if let Some(result) = command_result { + return self.apply_cmd_result(result); + } + + Message::Undo + } + + "REDO" => Message::Redo, + other => Message::Command(other.to_string()), - }; - self.update(message) + }; + + self.update(message) } }