From a98e600f09322442f4356507d86e92cdbc34b6f6 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Wed, 7 Oct 2026 11:40:37 +0300 Subject: [PATCH] Command line: the bare-word probe keeps no empty undo step Co-Authored-By: Claude Opus 5.5 --- src/app/command_driver/utilities.rs | 5 +++++ src/app/history.rs | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/app/command_driver/utilities.rs b/src/app/command_driver/utilities.rs index 943c3630d..84ee63d47 100644 --- a/src/app/command_driver/utilities.rs +++ b/src/app/command_driver/utilities.rs @@ -798,9 +798,14 @@ impl OpenCADStudio { { return self.dispatch_command(cmd); } + // Close an earlier step first so only what the probe opens is dropped below. + self.finish_pending_history(i); let start_task = self.dispatch_command(tokens[0]); if self.tabs[i].active_cmd.is_none() { // Not an interactive tool — an inline-argument command (`PDMODE 3`). + // The bare word only probed it: a step it kept without changing + // anything is not an undo step of its own. + self.drop_unchanged_pending_history(i); return self.dispatch_command(cmd); } let toks: Vec = tokens.iter().map(|s| s.to_string()).collect(); diff --git a/src/app/history.rs b/src/app/history.rs index ffe243c3c..3510ea040 100644 --- a/src/app/history.rs +++ b/src/app/history.rs @@ -341,6 +341,15 @@ impl OpenCADStudio { self.push_undo_entry(i, HistorySnapshot::Delta(Box::new(delta))); } + /// Finish the pending history step, dropping it when it changed nothing + /// even if it was opened as a mark ([`Self::push_undo_mark`]). + pub(super) fn drop_unchanged_pending_history(&mut self, i: usize) { + if let Some(pending) = self.tabs[i].history.pending.as_mut() { + pending.keep_empty = false; + } + self.finish_pending_history(i); + } + pub(super) fn finish_all_pending_history(&mut self) { for i in 0..self.tabs.len() { self.finish_pending_history(i);