fmt: format the print and save script changes

This commit is contained in:
dotCooCoo committed 2026-11-29 14:28:06 -08:00
1 parent c6b5899534
commit 9fb8974575
3 files changed
+7 -15

No files matched your search

+1 -4
View File
@@ -569,10 +569,7 @@ pub(super) fn exactly(h: &Host, f: impl FnOnce() -> Answer) -> Answer {
/// The path to give a command for the real path `real`.
pub(super) fn plain(real: std::path::PathBuf) -> std::result::Result<String, HostError> {
crate::cmd::findfiles::plain(real)
.into_os_string()
.into_string()
.map_err(|_| HostError::Error("Script file path is not valid UTF-8".into()))
crate::cmd::findfiles::plain(real).into_os_string().into_string().map_err(|_| HostError::Error("Script file path is not valid UTF-8".into()))
}
/// `document.saveAs(file, options?)`: `file.saveAs` on the document, in the format the options'
+5 -6
View File
@@ -70,7 +70,8 @@ fn print_blank_assigned_range_clears_the_saved_range() {
&format!(
"Folder.userData; var o = new PrintOptions(); o.jobOptions.file = new File({});
o.jobOptions.artboardRange = '{}'; app.activeDocument.print(o);",
quoted(&dir.join(name)), range
quoted(&dir.join(name)),
range
),
);
assert_eq!(pages(&dir.join(name)).len(), s.active().unwrap().doc.artboards.len());
@@ -93,7 +94,8 @@ fn print_uses_the_assigned_file_object_after_its_path_changes() {
app.activeDocument.print(o); vc.log(o.jobOptions.file === f);
vc.log(f.rename('renamed.pdf')); app.activeDocument.print(o);
o.jobOptions.file = null; vc.log(o.jobOptions.file == null);",
quoted(&dir.join("old.pdf")), quoted(&dir.join("new.ps"))
quoted(&dir.join("old.pdf")),
quoted(&dir.join("new.ps"))
),
);
assert_eq!(out, json!([true, true, true, true, true]));
@@ -137,10 +139,7 @@ fn print_dot_ps_file_names_write_postscript() {
logged(
&mut s,
&base,
&format!(
"Folder.userData; var o = new PrintOptions(); o.jobOptions.file = new File({}); app.activeDocument.print(o);",
quoted(&path)
),
&format!("Folder.userData; var o = new PrintOptions(); o.jobOptions.file = new File({}); app.activeDocument.print(o);", quoted(&path)),
);
assert!(std::fs::read(&path).unwrap().starts_with(b"%!PS"));
}
+1 -5
View File
@@ -103,11 +103,7 @@ fn script_file_commands_refuse_non_utf8_resolved_paths() {
std::os::unix::fs::symlink(&target, &link).unwrap();
let lossy = PathBuf::from(target.to_string_lossy().into_owned());
std::fs::write(&lossy, &bytes).unwrap();
for call in [
"app.activeDocument.saveAs(f);",
"app.activeDocument.exportFile(f, ExportType.SVG);",
"app.open(f);",
] {
for call in ["app.activeDocument.saveAs(f);", "app.activeDocument.exportFile(f, ExportType.SVG);", "app.open(f);"] {
let alias = if call.contains("exportFile") {
let alias = dir.join("alias.svg");
std::os::unix::fs::symlink(&target, &alias).unwrap();