Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

rustfmt

moppeeer08bab7a4776d
diff --git a/crates/engine/src/cmd/find/tests.rs b/crates/engine/src/cmd/find/tests.rs
index a60b40ebf..ae8742702 100644
--- a/crates/engine/src/cmd/find/tests.rs
+++ b/crates/engine/src/cmd/find/tests.rs
@@ -621,26 +621,26 @@ fn document_scope_searches_and_changes_table_cells() {
assert_eq!(s.execute("find.find", &json!({"find": "13.00", "scope": "document"})).unwrap().as_array().unwrap().len(), 2);
}
- /// Change (`found`) on text Find Next found in a table cell changes it there, leaves the
- /// same text in the story alone, and Find Next goes on after it.
- #[test]
- fn change_changes_the_text_find_next_found_in_a_cell() {
- let (mut s, sid) = scope_session("red here");
- scope_select(&mut s, sid, 0, 0);
- let table = s.execute("table.insert", &json!({"rows": 1, "cols": 2})).unwrap()["table"].as_u64().unwrap();
- s.execute("table.setCell", &json!({"row": 0, "col": 1, "text": "red"})).unwrap();
- let p = json!({"find": "red", "change": "blue", "scope": "document"});
- let hit = s.execute("find.next", &p).unwrap();
- assert_eq!(hit["cell"], json!({"table": table, "row": 0, "col": 1}), "{hit}");
- let mut change = p.clone();
- change["found"] = json!(true);
- assert_eq!(s.execute("find.change", &change).unwrap()["count"], 1);
- let t = s.execute("table.get", &json!({"table": table})).unwrap();
- assert_eq!(t["cells"][1]["text"], "blue");
- assert!(s.doc().unwrap().doc.story(sid).unwrap().text.contains("red here"), "the story's red stays");
- let next = s.execute("find.next", &p).unwrap();
- assert!(next.get("cell").is_none() && next.get("start").is_some(), "on to the story: {next}");
- }
+/// Change (`found`) on text Find Next found in a table cell changes it there, leaves the
+/// same text in the story alone, and Find Next goes on after it.
+#[test]
+fn change_changes_the_text_find_next_found_in_a_cell() {
+ let (mut s, sid) = scope_session("red here");
+ scope_select(&mut s, sid, 0, 0);
+ let table = s.execute("table.insert", &json!({"rows": 1, "cols": 2})).unwrap()["table"].as_u64().unwrap();
+ s.execute("table.setCell", &json!({"row": 0, "col": 1, "text": "red"})).unwrap();
+ let p = json!({"find": "red", "change": "blue", "scope": "document"});
+ let hit = s.execute("find.next", &p).unwrap();
+ assert_eq!(hit["cell"], json!({"table": table, "row": 0, "col": 1}), "{hit}");
+ let mut change = p.clone();
+ change["found"] = json!(true);
+ assert_eq!(s.execute("find.change", &change).unwrap()["count"], 1);
+ let t = s.execute("table.get", &json!({"table": table})).unwrap();
+ assert_eq!(t["cells"][1]["text"], "blue");
+ assert!(s.doc().unwrap().doc.story(sid).unwrap().text.contains("red here"), "the story's red stays");
+ let next = s.execute("find.next", &p).unwrap();
+ assert!(next.get("cell").is_none() && next.get("start").is_some(), "on to the story: {next}");
+}
fn child_scope_session(note: bool, child: &str) -> (Session, designcraft_doc::StoryId, designcraft_doc::TextSel) {
let (mut s, sid) = scope_session("red");
diff --git a/crates/ui-egui/src/dialogs/tests.rs b/crates/ui-egui/src/dialogs/tests.rs
index 9d392ed90..153a83486 100644
--- a/crates/ui-egui/src/dialogs/tests.rs
+++ b/crates/ui-egui/src/dialogs/tests.rs
@@ -1647,14 +1647,14 @@ fn dialog_frame(app: &mut DesignApp, ctx: &egui::Context, screen: egui::Rect, ev
labels
}
- /// What Find/Change's Search list shows for a scope.
- fn scope_label(scope: &str) -> &'static str {
- match scope {
- "story" => "Story",
- "selection" => "Selection",
- _ => "Document",
- }
+/// What Find/Change's Search list shows for a scope.
+fn scope_label(scope: &str) -> &'static str {
+ match scope {
+ "story" => "Story",
+ "selection" => "Selection",
+ _ => "Document",
}
+}
fn visible_label(labels: &[(String, egui::Rect, egui::Rect)], screen: egui::Rect, expected: &str) -> egui::Rect {
let (_, rect, clip) = labels.iter().find(|(text, _, _)| text.trim() == expected).unwrap_or_else(|| panic!("{expected} is painted"));
@@ -1739,8 +1739,8 @@ fn scope_dialog_with_tool(text: &str, end: usize, tool: Option<&str>) -> (Design
for _ in 0..3 {
dialog_frame(&mut app, &ctx, screen, vec![]);
}
- scope_click(&mut app, &ctx, screen, "Document");
- scope_click(&mut app, &ctx, screen, "Selection");
+ scope_click(&mut app, &ctx, screen, "Document");
+ scope_click(&mut app, &ctx, screen, "Selection");
assert_eq!(app.ui.dialog.as_ref().unwrap().s("scope"), "selection");
(app, ctx, screen, sid)
}
@@ -3613,10 +3613,7 @@ fn a_change_format_goes_with_change_all() {
let mut d = Dialog::new("findChange", json!({"find": "cook"}));
d.fields.insert(CHANGE_FORMAT.into(), json!({"charStyle": "eggs", "paraStyle": "Method", "chars": {"underline": true}}));
let p = find_change_params(&d);
- assert_eq!(
- (p["charStyle"].clone(), p["paraStyle"].clone(), p["attrs"].clone()),
- (json!("eggs"), json!("Method"), json!({"underline": true}))
- );
+ assert_eq!((p["charStyle"].clone(), p["paraStyle"].clone(), p["attrs"].clone()), (json!("eggs"), json!("Method"), json!({"underline": true})));
assert_eq!(format_summary("en", d.fields.get(CHANGE_FORMAT)), "Character Style: eggs + Paragraph Style: Method + Underline: on");
assert!(find_change_params(&Dialog::new("findChange", json!({"find": "cook"}))).get("attrs").is_none());
// A Find Format goes with every search.