diff --git a/crates/ui-egui/src/script_runs.rs b/crates/ui-egui/src/script_runs.rs index 1a17eb6974..11d6c7e599 100644 --- a/crates/ui-egui/src/script_runs.rs +++ b/crates/ui-egui/src/script_runs.rs @@ -130,7 +130,7 @@ fn ask(app: &mut VectorcraftApp) -> bool { /// a folder that is there and cannot be read show in the status bar ([`reply_notes`]). /// → `script.run`'s reply, with `startup` holding `script.startup.run`'s when the startup scripts /// were run: the chosen script's own reply when it ran to its end at once, `{running: true, name}` -/// when it is running, or `{running: true, queued: true}` while a startup script runs before it. +/// when it is running, or `{running: true, queued: true}` while the chosen script waits to start. /// A chosen script that could not start gives its error, as `script.run` does. pub(crate) fn run_chosen(app: &mut VectorcraftApp, params: Value) -> Result { if app.session.startup_skip().is_some() { @@ -146,7 +146,7 @@ pub(crate) fn run_chosen(app: &mut VectorcraftApp, params: Value) -> Result json!({"running": true, "queued": true}), + None if app.session.startup_script_running() || app.session.script_name().is_none() => json!({"running": true, "queued": true}), None => json!({"running": true, "name": app.session.script_name().unwrap_or_default()}), }; if let Some(o) = reply.as_object_mut() { diff --git a/crates/ui-egui/src/tests/scripts_menu.rs b/crates/ui-egui/src/tests/scripts_menu.rs index 0683a1fe6b..300e0dbb32 100644 --- a/crates/ui-egui/src/tests/scripts_menu.rs +++ b/crates/ui-egui/src/tests/scripts_menu.rs @@ -632,7 +632,9 @@ fn a_menu_run_after_a_first_startup_script_that_cannot_start_shows_it_and_runs_t app.session.prefs.show_external_script_warning = false; app.run("prefs.set", json!({"key": "runStartupScripts", "value": true})).unwrap(); app.status("before"); - menus::run_ui_command(&mut app, "ui.runScript", &json!({ "source": DRAW, "name": "chosen" })).unwrap().unwrap(); + let reply = menus::run_ui_command(&mut app, "ui.runScript", &json!({ "source": DRAW, "name": "chosen" })).unwrap().unwrap(); + assert_eq!(reply["running"], true, "{reply}"); + assert_eq!(reply["queued"], true, "{reply}"); let shown = format!("0.jsx: {}", vectorcraft_engine::cmd::scripts::TOO_LARGE); assert_eq!(app.ui.status, shown); finish(&mut app);