Scripts: File › Scripts runs the text its check read, with includes from the checked folder

The menu item checked a listed script and then ran script.run by its path,
which opened the file again; a link put in place of the file or a folder on
its path in between could make it run a file the check never saw, and the
include folder was looked up from the path again as well.

script.run takes installed: true. With a path it reads the file once through
script::folder::read, runs that text, and reads #include and $.evalFile in the
Scripts folder's real path followed by the names that read found. The menu
item runs script.run {path, installed: true}.
This commit is contained in:
dotCooCoo
2026-11-14 15:37:18 -08:00
parent 9ddbf25bef
commit 828817c4b2
8 changed files with 131 additions and 23 deletions
+6 -4
View File
@@ -295,12 +295,14 @@ fn display(path: &Path) -> Arc<str> {
impl Files {
/// The files of a run of the script at `path` (`None` for a script given as text), with the
/// `JSINCLUDE` folders `jsinclude`.
pub(crate) fn new(path: Option<&str>, jsinclude: Vec<PathBuf>) -> Self {
let real = path.and_then(|p| std::fs::canonicalize(p).ok());
/// `JSINCLUDE` folders `jsinclude`. `checked` is the script's real path when the read of its text
/// found it, which the run's folder then comes from; without it, `path` is looked up.
pub(crate) fn new(path: Option<&str>, checked: Option<PathBuf>, jsinclude: Vec<PathBuf>) -> Self {
let scope_of_checked = checked.as_deref().and_then(Path::parent).map(|d| ScriptScope::of_real_folder(d.to_path_buf()));
let real = checked.or_else(|| path.and_then(|p| std::fs::canonicalize(p).ok()));
let dir = real.as_deref().and_then(folder_of);
Self {
scope: dir.as_deref().map(ScriptScope::of_folder).unwrap_or_default(),
scope: scope_of_checked.or_else(|| dir.as_deref().map(ScriptScope::of_folder)).unwrap_or_default(),
jsinclude,
include_path: Vec::new(),
files: 0,