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}"][..], ] {