Scripts: fix a run's linked files at its first step

A run whose first step is an exact document.open still reads the open
documents' linked files then, so a link retargeted while the run is paused
gives a later command no read access to the new target. The open itself
still gets no linked-file access.
This commit is contained in:
dotCooCoo committed 2026-12-02 14:10:57 -08:00
1 parent b91beb68fd
commit cb98b72a58
1 file changed
+3 -1
+3 -1
View File
@@ -1349,7 +1349,9 @@ fn step(s: &mut Session, host: &Host, id: &str, params: &Value) -> Result<(Value
// the open documents; it also reads the files the documents open when the run began link to, as the
// person left them. A document a script's command opened gives it no file.
let documents = s.docs.iter().filter_map(|d| d.as_person_left().and_then(|(_, path, _)| path.map(str::to_string))).collect();
let linked = if id == "document.open" && host.disk.borrow().exact { Default::default() } else { host.linked() };
// The linked files are fixed at the run's first step, also when that step is an exact open that gets none.
let linked = host.linked();
let linked = if id == "document.open" && host.disk.borrow().exact { Default::default() } else { linked };
let gate = host.disk.borrow().gate(documents, linked);
let was: Vec<(u64, RunDoc)> = s.docs.iter().map(|d| (d.uid, (d.doc.clone(), d.path.clone(), d.links_from.clone()))).collect();
let r = crate::file_access::with_script_gate(gate, || s.execute(id, params));