CLI: run without --file uses the region's paper, like convert (#3152)

A bare `run` built its document with Document::new() (Letter) and never went
through file.new, so it skipped the system region's paper. It now runs
file.new, as `run --template` already did.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Naxvog
2026-10-19 22:54:41 +02:00
committed by Naxvog
co-authored by Claude Opus 5.5
parent e6c5a701dd
commit fec27d66d1
2 changed files with 6 additions and 4 deletions
+4 -3
View File
@@ -471,12 +471,13 @@ fn run<S: AsRef<OsStr>>(args: &[S]) -> Result<(), Failure> {
}
let mut s = match (from_file, from_template) {
(Some(f), _) => open(&f, password.as_deref())?,
(None, Some(t)) => {
// Both go through `file.new`, which puts a blank document on the region's paper (#3152).
(None, t) => {
let mut s = session(wordcraft_doc::Document::new());
s.run("file.new", &json!({"template": t})).map_err(|e| e.to_string())?;
let params = t.map_or_else(|| json!({}), |t| json!({"template": t}));
s.run("file.new", &params).map_err(|e| e.to_string())?;
s
}
_ => session(wordcraft_doc::Document::new()),
};
if let Some(name) = arg_value(&rest, "--author") {
set_author(&mut s, &name)?;
+2 -1
View File
@@ -40,10 +40,11 @@ fn html_converts_onto_the_region_paper() {
#[test]
fn every_run_session_follows_the_region() {
// `run --file`, `run --template` and a bare `run` all start a session in the system region,
// `run --file`, `run --template` and a bare `run` (with or without `file.new`) all start a session in the system region,
// so `file.new` gives the same paper whichever way the session began.
for args in [
&["run", "--cmd", "file.new", "--save", "{out}"][..],
&["run", "--cmd", "text.insert={\"text\":\"x\"}", "--save", "{out}"][..],
&["run", "--template", "blank", "--save", "{out}"][..],
&["run", "--file", "{src}", "--cmd", "file.new", "--save", "{out}"][..],
] {