From fec27d66d1e4b29dec9b4b4bace37c2776b940d8 Mon Sep 17 00:00:00 2001 From: Naxvog <4963183+naxvog@users.noreply.github.com> Date: Mon, 19 Oct 2026 22:54:17 +0200 Subject: [PATCH] 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 --- apps/wordcraft-cli/src/main.rs | 7 ++++--- apps/wordcraft-cli/tests/convert_region.rs | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/wordcraft-cli/src/main.rs b/apps/wordcraft-cli/src/main.rs index 446b902fa..78e4bbfa1 100644 --- a/apps/wordcraft-cli/src/main.rs +++ b/apps/wordcraft-cli/src/main.rs @@ -471,12 +471,13 @@ fn run>(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", ¶ms).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)?; diff --git a/apps/wordcraft-cli/tests/convert_region.rs b/apps/wordcraft-cli/tests/convert_region.rs index 5f9fb4b53..9b3553669 100644 --- a/apps/wordcraft-cli/tests/convert_region.rs +++ b/apps/wordcraft-cli/tests/convert_region.rs @@ -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}"][..], ] {