forked from 1b-agent/opencadstudio-upstream
feat: SCRIPTCOMMANDS setting to turn script-driven commands off
A saved user preference (on by default) toggled by the SCRIPTCOMMANDS command gates HostApi::run_command; Cancel stays allowed so a waiting command is never stranded. The runner refuses the SCRIPTCOMMANDS command itself, so a script cannot change it. Documents why no helper-thread or stack-growing dependency was added: native builds link with at least 8 MiB, the nesting depth is fixed, and the deepest step found needs 2 to 4 MiB in a debug build. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a25ae4f8c0
commit
2ed41586de
8 files changed
+120
-15
No files matched your search
@@ -476,6 +476,10 @@ pub struct UserSettings {
|
||||
/// Minutes between autosaves to a `.sv$` recovery file (SAVETIME command).
|
||||
/// 0 disables autosave.
|
||||
pub savetime_min: i32,
|
||||
/// SCRIPTCOMMANDS: whether a script (the Python plugin) may run OCS commands
|
||||
/// through the host. On by default; a user turns it off with the
|
||||
/// `SCRIPTCOMMANDS 0` command, and a script cannot change it.
|
||||
pub script_commands: bool,
|
||||
/// File type and version used when a new/unsaved drawing is first saved.
|
||||
/// Existing drawings keep their own type and version.
|
||||
pub default_save_format: String,
|
||||
@@ -676,6 +680,7 @@ impl Default for UserSettings {
|
||||
constraint_bar_display: 3,
|
||||
constraint_bar_mode: 4095,
|
||||
savetime_min: 10,
|
||||
script_commands: true,
|
||||
default_save_format: crate::io::DEFAULT_SAVE_FORMAT.to_string(),
|
||||
pick_add: true,
|
||||
pick_drag_rect: false,
|
||||
@@ -789,6 +794,19 @@ mod tests {
|
||||
assert_eq!(cfg.settings.savetime_min, 42);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_commands_default_on_and_survive_a_round_trip() {
|
||||
let missing: crate::app::config::AppConfig =
|
||||
serde_json::from_str(r#"{"settings": {"pick_add": false}}"#).unwrap();
|
||||
assert!(missing.settings.script_commands, "an old config keeps scripts allowed");
|
||||
let off: crate::app::config::AppConfig =
|
||||
serde_json::from_str(r#"{"settings": {"script_commands": false}}"#).unwrap();
|
||||
assert!(!off.settings.script_commands);
|
||||
let text = serde_json::to_string(&off).unwrap();
|
||||
let back: crate::app::config::AppConfig = serde_json::from_str(&text).unwrap();
|
||||
assert!(!back.settings.script_commands);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn isometric_drafting_never_persists_or_loads() {
|
||||
// A persisted On used to bring the isoplane crosshair (vertical +
|
||||
|
||||
Reference in new issue
Block a user