diff --git a/crates/improvise-command/src/command/cmd/cell.rs b/crates/improvise-command/src/command/cmd/cell.rs index 36e4a34f..5675ab5f 100644 --- a/crates/improvise-command/src/command/cmd/cell.rs +++ b/crates/improvise-command/src/command/cmd/cell.rs @@ -3,9 +3,7 @@ use crate::model::cell::{CellKey, CellValue}; use crate::ui::effect::{self, Effect, ViewTarget}; use crate::view::synthetic_record_info; -use super::core::{ - AGGREGATE_REFUSAL, Cmd, CmdContext, INSIDE_A_DRILL_REFUSAL, NO_VALUE_REFUSAL, -}; +use super::core::{AGGREGATE_REFUSAL, Cmd, CmdContext, INSIDE_A_DRILL_REFUSAL, NO_VALUE_REFUSAL}; #[cfg(test)] mod tests { @@ -399,7 +397,11 @@ mod tests { app.cursor_mut().selected = (1, col_of(&app, "Cost")); press(&mut app, 'x'); let wb = &app.model_state.workbook; - assert_eq!(wb.model.get_cell(&record("West", "Cost")), None, "West/Cost"); + assert_eq!( + wb.model.get_cell(&record("West", "Cost")), + None, + "West/Cost" + ); assert_eq!( wb.model.get_cell(&record("East", "Cost")), Some(&CellValue::Number(700.0)), @@ -418,7 +420,10 @@ mod tests { let before = crate::persistence::format_md(&app.model_state.workbook); app.cursor_mut().selected = (1, col_of(&app, "Region")); press(&mut app, 'x'); - assert_eq!(crate::persistence::format_md(&app.model_state.workbook), before); + assert_eq!( + crate::persistence::format_md(&app.model_state.workbook), + before + ); assert!( app.view_state.status_msg.ends_with(NO_VALUE_REFUSAL), "declined out loud, got {:?}", @@ -464,10 +469,15 @@ mod tests { assert_eq!(app.layout.col_label(2), "Profit", "setup: on the formula"); press(&mut app, 'p'); let (text, back) = saved_and_reloaded(&app.model_state.workbook); - assert!(!text.contains("_Measure=Profit"), "saved under the formula:\n{text}"); + assert!( + !text.contains("_Measure=Profit"), + "saved under the formula:\n{text}" + ); assert_eq!(back.model.get_cell(&record("West", "Profit")), None); assert!( - app.view_state.status_msg.contains("Profit is computed by a formula"), + app.view_state + .status_msg + .contains("Profit is computed by a formula"), "declined out loud, got {:?}", app.view_state.status_msg ); @@ -492,14 +502,21 @@ mod tests { assert!(app.view_state.mode.is_editing(), "setup: editing West/Cost"); app.handle_key(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE)) .unwrap(); - assert_eq!(app.cursor().selected, (1, 2), "setup: Tab moved onto Profit"); + assert_eq!( + app.cursor().selected, + (1, 2), + "setup: Tab moved onto Profit" + ); for c in "7".chars() { press(&mut app, c); } app.handle_key(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE)) .unwrap(); let (text, back) = saved_and_reloaded(&app.model_state.workbook); - assert!(!text.contains("_Measure=Profit"), "saved under the formula:\n{text}"); + assert!( + !text.contains("_Measure=Profit"), + "saved under the formula:\n{text}" + ); assert_eq!(back.model.get_cell(&record("West", "Profit")), None); } } @@ -592,7 +609,6 @@ fn aggregates(ctx: &CmdContext, key: &CellKey) -> bool { }) } - // ── View commands ──────────────────────────────────────────────────────────── #[derive(Debug)] diff --git a/crates/improvise-command/src/command/cmd/grid.rs b/crates/improvise-command/src/command/cmd/grid.rs index c191daca..24a2fb65 100644 --- a/crates/improvise-command/src/command/cmd/grid.rs +++ b/crates/improvise-command/src/command/cmd/grid.rs @@ -33,7 +33,10 @@ mod tests { let (text, back) = saved_and_reloaded(&app.model_state.workbook); let data = text.split("## Data").nth(1).expect("a data section"); - assert!(!data.contains("Q2"), "a group coordinate was saved:\n{text}"); + assert!( + !data.contains("Q2"), + "a group coordinate was saved:\n{text}" + ); assert_eq!(non_item_coordinates(&back), Vec::<(String, String)>::new()); } @@ -47,12 +50,19 @@ mod tests { app.cursor_mut().selected = (1, 1); press(&mut app, 'i'); app.handle_key(enter).unwrap(); - assert_eq!(app.cursor().selected, (2, 1), "setup: Enter moved onto the fold"); + assert_eq!( + app.cursor().selected, + (2, 1), + "setup: Enter moved onto the fold" + ); press(&mut app, '7'); app.handle_key(enter).unwrap(); let (text, back) = saved_and_reloaded(&app.model_state.workbook); let data = text.split("## Data").nth(1).expect("a data section"); - assert!(!data.contains("Q2"), "a group coordinate was saved:\n{text}"); + assert!( + !data.contains("Q2"), + "a group coordinate was saved:\n{text}" + ); assert_eq!(non_item_coordinates(&back), Vec::<(String, String)>::new()); } @@ -79,7 +89,10 @@ mod tests { app.view_state.status_msg ); let (text, _) = saved_and_reloaded(&app.model_state.workbook); - assert!(!text.contains("hidden:"), "a hidden entry was saved:\n{text}"); + assert!( + !text.contains("hidden:"), + "a hidden entry was saved:\n{text}" + ); // The control: the row above is an item, and H hides it. app.cursor_mut().selected = (1, 1); diff --git a/crates/improvise-command/src/command/cmd/mod.rs b/crates/improvise-command/src/command/cmd/mod.rs index f895d64d..9c46d72e 100644 --- a/crates/improvise-command/src/command/cmd/mod.rs +++ b/crates/improvise-command/src/command/cmd/mod.rs @@ -152,7 +152,10 @@ pub(super) mod test_helpers { let mut app = crate::ui::app::App::new(wb, None); app.rebuild_layout(); app.cursor_mut().selected = (2, 1); - assert!(app.layout.folds_a_group(2, 1), "setup: the cursor is on the fold"); + assert!( + app.layout.folds_a_group(2, 1), + "setup: the cursor is on the fold" + ); assert_eq!(app.layout.row_label(2), "Q2", "setup: the fold is Q2's row"); app } diff --git a/crates/improvise-command/src/command/cmd/mode.rs b/crates/improvise-command/src/command/cmd/mode.rs index f87a2312..2a90c51c 100644 --- a/crates/improvise-command/src/command/cmd/mode.rs +++ b/crates/improvise-command/src/command/cmd/mode.rs @@ -380,7 +380,9 @@ impl Cmd for EditOrDrill { // The same question `cell_id` asks, off the same predicate. In records mode // the synthetic key names no measure, so the record's key is resolved. if let Some(formula) = ctx.owning_formula() { - return vec![effect::refuse(super::core::derived_refusal(&formula.target))]; + return vec![effect::refuse(super::core::derived_refusal( + &formula.target, + ))]; } vec![ Box::new(effect::SetBuffer { diff --git a/crates/improvise-command/src/command/keymap.rs b/crates/improvise-command/src/command/keymap.rs index 189d733c..5aca92a9 100644 --- a/crates/improvise-command/src/command/keymap.rs +++ b/crates/improvise-command/src/command/keymap.rs @@ -483,7 +483,11 @@ mod tests { fn no_normal_mode_key_pressed_on_a_fold_stores_a_group_coordinate() { use improvise_protocol::key::KeyEvent; let ks = KeymapSet::default_keymaps(); - let normal = ks.maps().get(&ModeKey::Normal).expect("a Normal keymap").clone(); + let normal = ks + .maps() + .get(&ModeKey::Normal) + .expect("a Normal keymap") + .clone(); let mods = [ KeyModifiers::NONE, KeyModifiers::SHIFT, @@ -507,7 +511,9 @@ mod tests { } } assert!( - strokes.iter().any(|s| s == &[(KeyCode::Char('p'), KeyModifiers::NONE)]), + strokes + .iter() + .any(|s| s == &[(KeyCode::Char('p'), KeyModifiers::NONE)]), "the sweep reaches paste" ); for stroke in &strokes { diff --git a/crates/improvise-wasm-client/tests/lockstep.rs b/crates/improvise-wasm-client/tests/lockstep.rs index 4796ae44..c7aa4c1f 100644 --- a/crates/improvise-wasm-client/tests/lockstep.rs +++ b/crates/improvise-wasm-client/tests/lockstep.rs @@ -1871,8 +1871,14 @@ fn x_in_records_mode_clears_the_record_the_browser_clears() { both_ends(&mut app, &mut twin, &mut client, "x"); let model = &app.model_state.workbook.model; - assert_eq!(model.get_cell(&north_revenue().with("Region", "South")), None); - assert!(model.get_cell(&north_revenue()).is_some(), "North is untouched"); + assert_eq!( + model.get_cell(&north_revenue().with("Region", "South")), + None + ); + assert!( + model.get_cell(&north_revenue()).is_some(), + "North is untouched" + ); } /// `key` at `at` on a host and on a client seeded from it: neither writes. @@ -1881,11 +1887,21 @@ fn declines_on_both_ends(mut app: App, at: (usize, usize), key: char) { app.view_state.yanked = Some(improvise_protocol::CellValue::Number(99.0)); app.cursor_mut().selected = at; let client = client_ready_to_edit(&app, (6, 6)); - assert!(!composes_a_write(&client, event), "the browser composed a write"); + assert!( + !composes_a_write(&client, event), + "the browser composed a write" + ); let before = document_text(&app); reduce_key(&mut app, event); - assert_eq!(document_text(&app), before, "the TUI wrote where the browser declines"); - assert!(!app.view_state.status_msg.is_empty(), "the TUI declined silently"); + assert_eq!( + document_text(&app), + before, + "the TUI wrote where the browser declines" + ); + assert!( + !app.view_state.status_msg.is_empty(), + "the TUI declined silently" + ); } /// improvise-54g1: `p` on a formula-owned cell. The control is the stored cell @@ -1893,7 +1909,11 @@ fn declines_on_both_ends(mut app: App, at: (usize, usize), key: char) { #[test] fn p_onto_a_formula_owned_cell_declines_on_both_ends() { let app = yank_host(); - assert_eq!(app.layout.col_label(3), "Profit", "setup: column 3 is the formula"); + assert_eq!( + app.layout.col_label(3), + "Profit", + "setup: column 3 is the formula" + ); declines_on_both_ends(app, (1, 3), 'p'); let mut app = yank_host(); @@ -1901,7 +1921,10 @@ fn p_onto_a_formula_owned_cell_declines_on_both_ends() { app.cursor_mut().selected = (1, 2); let client = client_ready_to_edit(&app, (6, 6)); let p = KeyEvent::new(KeyCode::Char('p'), KeyModifiers::NONE); - assert!(composes_a_write(&client, p), "the control: Cost is settable"); + assert!( + composes_a_write(&client, p), + "the control: Cost is settable" + ); } /// improvise-gw18/l4mp: `p` and `x` on a collapsed group's fold, off the origin.