From e5f33cadcf9ce0a8cdc4f07c788c173ccc1e18b7 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Mon, 30 Nov 2026 14:20:12 -0800 Subject: [PATCH 1/3] Expand Paste Lorem Ipsum to a full sample paragraph --- crates/engine-core/src/cmd/type_extra_cmds.rs | 19 +++++++++++++-- .../src/cmd/type_paste_lorem_length_tests.rs | 24 +++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs diff --git a/crates/engine-core/src/cmd/type_extra_cmds.rs b/crates/engine-core/src/cmd/type_extra_cmds.rs index c3ce98effe..e22b67bdf2 100644 --- a/crates/engine-core/src/cmd/type_extra_cmds.rs +++ b/crates/engine-core/src/cmd/type_extra_cmds.rs @@ -21,8 +21,23 @@ use crate::type_cmds::{ }; use crate::{EngineError, Result, Session}; -/// Photoshop's Paste Lorem Ipsum filler. -pub const LOREM_IPSUM: &str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; +/// One paragraph of Paste Lorem Ipsum filler. +pub const LOREM_IPSUM: &str = concat!( + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ", + "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ", + "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ", + "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ", + "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit. ", + "Dum verba in pagina disponuntur, lector ordinem litterarum et spatium inter lineas considerat. ", + "Scriptor idem initium retinet et diversas sententias addit, ut forma paginae sine imagine clarius appareat. ", + "Alia verba brevia sunt, alia longiora, et finis cuiusque lineae pro latitudine spatii mutatur. ", + "Interdum pagina amplior plures litteras recipit, interdum angusta paucis verbis impletur. ", + "Utraque forma exemplum praebet, dum verba suo ordine manent.", +); + +#[cfg(test)] +#[path = "type_paste_lorem_length_tests.rs"] +mod paste_lorem_length_tests; // ---------- predicates ---------- diff --git a/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs b/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs new file mode 100644 index 0000000000..4921db325e --- /dev/null +++ b/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs @@ -0,0 +1,24 @@ +use serde_json::json; + +use crate::Session; + +#[test] +fn paste_lorem_adds_one_full_paragraph_without_growing_the_type_box() { + let mut session = Session::new(); + session.execute("file.new", json!({"width": 240, "height": 120})).unwrap(); + + for params in [json!({"x": 10, "y": 20, "text": "Existing"}), json!({"box": [10, 10, 20, 18], "text": "Existing"})] { + let layer = session.execute("type.create", params).unwrap()["layer"].as_u64().unwrap(); + let before = session.execute("type.info", json!({"layer": layer})).unwrap(); + let reply = session.execute("type.pasteLoremIpsum", json!({"layer": layer, "at": 0})).unwrap(); + let after = session.execute("type.info", json!({"layer": layer})).unwrap(); + let filler = after["text"].as_str().unwrap().strip_suffix("Existing").unwrap(); + let len = filler.chars().count(); + assert!((950..=1100).contains(&len), "expected about one thousand characters, got {len}"); + assert!(filler.starts_with("Lorem ipsum dolor sit amet")); + assert!(!filler.contains(['\r', '\n'])); + assert_eq!(reply["caret"], json!(len)); + assert!(!before["shape"].is_null()); + assert_eq!(after["shape"], before["shape"], "the full text is kept in the original point or paragraph geometry"); + } +} From d30f2ccb2693f398ed1c627811a830d4130ecb82 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Mon, 30 Nov 2026 15:02:26 -0800 Subject: [PATCH 2/3] Initialize commands in the Lorem Ipsum length test --- crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs b/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs index 4921db325e..fedb3dbf2c 100644 --- a/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs +++ b/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs @@ -1,10 +1,8 @@ use serde_json::json; -use crate::Session; - #[test] fn paste_lorem_adds_one_full_paragraph_without_growing_the_type_box() { - let mut session = Session::new(); + let mut session = crate::session(); session.execute("file.new", json!({"width": 240, "height": 120})).unwrap(); for params in [json!({"x": 10, "y": 20, "text": "Existing"}), json!({"box": [10, 10, 20, 18], "text": "Existing"})] { From 2b6a395181c6d9e8973aa6f3cc758dd6fa1a4954 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Mon, 30 Nov 2026 20:08:05 -0800 Subject: [PATCH 3/3] Require the complete Lorem Ipsum sample --- crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs b/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs index fedb3dbf2c..9e3d0f8244 100644 --- a/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs +++ b/crates/engine-core/src/cmd/type_paste_lorem_length_tests.rs @@ -1,5 +1,7 @@ use serde_json::json; +use super::LOREM_IPSUM; + #[test] fn paste_lorem_adds_one_full_paragraph_without_growing_the_type_box() { let mut session = crate::session(); @@ -12,6 +14,7 @@ fn paste_lorem_adds_one_full_paragraph_without_growing_the_type_box() { let after = session.execute("type.info", json!({"layer": layer})).unwrap(); let filler = after["text"].as_str().unwrap().strip_suffix("Existing").unwrap(); let len = filler.chars().count(); + assert_eq!(filler, LOREM_IPSUM); assert!((950..=1100).contains(&len), "expected about one thousand characters, got {len}"); assert!(filler.starts_with("Lorem ipsum dolor sit amet")); assert!(!filler.contains(['\r', '\n']));