Engine: stopping Record Actions waits while a macro in its workbook is being debugged

Stopping Record Actions saves a script into the workbook, which the debugger lock refuses while a
macro there is paused. The refusal came after Record Actions had taken its recording, so the
recording was lost. Stopping is now refused before anything changes, and stopping again after
the run saves the script.
This commit is contained in:
prxnvt
2026-10-22 02:26:32 -04:00
parent f553619b33
commit 6a004bf610
2 changed files with 10 additions and 1 deletions
+5 -1
View File
@@ -415,7 +415,11 @@ impl Session {
// touched wait, also when another command runs them (a script, or a recording that stops
// and saves). Only the run's own steps go ahead. Other workbooks stay editable.
let locked = self.active().is_some_and(|d| self.macro_debug.as_ref().is_some_and(|m| m.locks(d.uid) && !m.stepping()));
if spec.undoable && id != "macro.debug" && locked {
// Stopping Record Actions saves a script into the workbook; refuse it before it takes the
// recording, so stopping again after the run keeps what was recorded.
let stops_record_actions =
id == "automate.recordActions" && (params.get("stop").and_then(Json::as_bool) == Some(true) || self.recording.is_some());
if (spec.undoable || stops_record_actions) && id != "macro.debug" && locked {
return Err(EngineError::Disabled(id.to_string(), macros::debug::BUSY.into()));
}
let before = self.active().map(|d| (d.uid, d.wb.clone(), d.selection.clone()));
+5
View File
@@ -468,5 +468,10 @@ mod tests {
let r = s.execute("macro.debug", json!({"action": "step"})).unwrap();
assert_eq!(r["executed"], 2, "{r}");
assert!(s.macro_debug.is_none());
// The recording was kept: stopping now saves it.
let saved = s.execute("automate.recordActions", json!({"stop": true, "name": "S"})).unwrap();
assert_eq!(saved["saved"], "S", "{saved}");
let scripts = s.execute("automate.allScripts", json!({})).unwrap();
assert_eq!(scripts[0]["name"], "S", "{scripts}");
}
}