From f225cd102650a3b6fff93cc0b6b70bef35ed8697 Mon Sep 17 00:00:00 2001 From: prxnvt <53838599+prxnvt@users.noreply.github.com> Date: Sun, 25 Oct 2026 05:16:23 -0400 Subject: [PATCH] Engine: Check Macro waits while a macro is being debugged `macro.check` is a query, so the debugger's lock let it through, but its dry run runs the macro's steps, which the lock refuses: the check reported the lock as the failure of a step. It now waits with "Finish or stop the macro first", as other commands that change the workbook do. - Test: `between_steps_only_looking_around_runs_and_the_run_continues_where_it_was`. --- crates/engine/src/macros/debug.rs | 4 +++- crates/engine/src/tests/macros.rs | 2 ++ docs/macros.md | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/macros/debug.rs b/crates/engine/src/macros/debug.rs index acbc320f3..f5932daee 100644 --- a/crates/engine/src/macros/debug.rs +++ b/crates/engine/src/macros/debug.rs @@ -51,7 +51,9 @@ pub const LOOKS_AROUND: &[&str] = &[ /// Whether command `id` (a query when `query`) runs on a workbook the debugger locks. pub fn runs_while_locked(id: &str, query: bool) -> bool { - query || id == "macro.debug" || LOOKS_AROUND.contains(&id) + // `macro.check` is a query, but its dry run runs the macro's steps, which the lock refuses: it + // waits too, rather than report the lock as the failure of a step. + (query && id != "macro.check") || id == "macro.debug" || LOOKS_AROUND.contains(&id) } /// A macro being debugged. diff --git a/crates/engine/src/tests/macros.rs b/crates/engine/src/tests/macros.rs index 86a4e993c..13530cb9b 100644 --- a/crates/engine/src/tests/macros.rs +++ b/crates/engine/src/tests/macros.rs @@ -440,6 +440,8 @@ fn between_steps_only_looking_around_runs_and_the_run_continues_where_it_was() { assert!(busy(s.execute("file.save", json!({})))); assert!(busy(s.execute("automate.recordActions", json!({})))); assert!(busy(s.execute("cell.set", json!({"cell": "A1", "input": "x"})))); + // A check would dry-run the macro's steps, which the lock refuses: it waits too. + assert!(busy(s.execute("macro.check", json!({"name": "Sel"})))); assert!(!path.exists(), "nothing was saved"); // The next step runs on the run's sheet and selection, as macro.run would. let st = debug(&mut s, json!({"action": "step"})); diff --git a/docs/macros.md b/docs/macros.md index d88f940e0..4a6268da9 100644 --- a/docs/macros.md +++ b/docs/macros.md @@ -185,7 +185,8 @@ While a macro is being debugged, its workbook is locked between steps: only `mac `sheet.next` and `sheet.previous`, Go To, Go To Special, Find, Copy and the zoom commands), Switch Window, Close (which ends the run with its workbook) and Automate › Stop Action run there. Everything else, undoable or not, saving included, is refused with "Finish or stop the macro -first", also when another command runs it (stopping Record Actions saves a script). Other +first", also when another command runs it (stopping Record Actions saves a script), and so is +`macro.check`, whose dry run runs the macro's steps. Other workbooks stay editable. The person may look around between steps: before the next step runs, the debugger puts the active sheet and the selection back where the run left them, so the run goes on as `macro.run` would run it. A zoom change made meanwhile is part of the run, and is undone with