Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VdfEGXA7aJ6ftMsCc9PJze
This commit is contained in:
Edward Langley
2026-09-22 22:05:08 -07:00
parent aa959343a2
commit 8fb5f6b14a
6 changed files with 88 additions and 25 deletions
@@ -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)]
@@ -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);
@@ -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
}
@@ -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 {
@@ -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 {
+30 -7
View File
@@ -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.