diff --git a/crates/ui-egui/src/dialogs/script_run.rs b/crates/ui-egui/src/dialogs/script_run.rs index b7f3897931..1d54f82fd6 100644 --- a/crates/ui-egui/src/dialogs/script_run.rs +++ b/crates/ui-egui/src/dialogs/script_run.rs @@ -592,11 +592,12 @@ fn listed(prompt: StandardPrompt, r: &Value) -> StandardPrompt { }) .collect(); let needs = list(r, "needs").iter().filter_map(Value::as_str).filter(|n| matches!(*n, "files" | "dialogs" | "hostOnly")).filter_map(need_label); - let mut lines: Vec = Vec::new(); - lines.extend(outside); - lines.extend(needs.map(str::to_string)); - if !lines.is_empty() { - lines.insert(0, crate::i18n::colon(tl!("Outside the document"))); + // The needs come first, each a sentence of its own; the heading names only what the script does + // outside the document. + let mut lines: Vec = needs.map(str::to_string).collect(); + if !outside.is_empty() { + lines.push(crate::i18n::colon(tl!("Outside the document"))); + lines.extend(outside); } let includes = list(r, "includes"); if !includes.is_empty() { diff --git a/crates/ui-egui/src/tests/script_run.rs b/crates/ui-egui/src/tests/script_run.rs index 11d9a3ed0c..fcb0d8bbd2 100644 --- a/crates/ui-egui/src/tests/script_run.rs +++ b/crates/ui-egui/src/tests/script_run.rs @@ -541,6 +541,20 @@ fn the_warning_lists_what_a_scripts_included_files_reach() { let _ = std::fs::remove_dir_all(&dir); } +/// A script that opens a dialog and reaches nothing outside the document lists the need without the +/// outside-the-document heading. +#[test] +fn the_warning_lists_a_need_without_the_outside_heading() { + let mut app = app(); + menus::run_ui_command(&mut app, "ui.runScript", &json!({"source": "var w = new Window('dialog', 'Title');", "name": "dialog.js"})).unwrap().unwrap(); + assert_eq!(fields(&app, KIND)["reaches"]["outside"], json!([])); + let texts = dialog_texts(&mut app); + assert!(texts.iter().any(|t| t == script_check::need_label("dialogs").unwrap()), "{texts:?}"); + assert!(!texts.iter().any(|t| t == "Outside the document:"), "{texts:?}"); + cancel(&mut app, KIND); + finish(&mut app); +} + /// A script file that changes what it reaches while its warning is open does not run on Run: the /// warning opens again with the new report, and the next Run runs it. #[test]