Repository navigation
fix(engine): say which history an edit's memory check dropped (#2431) #2460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -664,7 +664,8 @@ mod tests { | |||||||
| let mark = session.notice_mark(); | ||||||||
| session.run("layer.addDataText", &json!({"fileName": "third.csv", "text": "a\n1\n"})).unwrap(); | ||||||||
| let notices = session.notices_since(mark); | ||||||||
| assert!(notices.iter().any(|n| n.text.contains("(3 before editing calc)")), "{notices:?}"); | ||||||||
| assert!(notices.iter().any(|n| n.text.contains("background edit of calc is dropped (3 Undo or Redo steps)")), "{notices:?}"); | ||||||||
| assert!(!notices.iter().any(|n| n.text.contains("make room")), "{notices:?}"); | ||||||||
| assert_eq!(session.undo_depth(), 2, "only the two later steps"); | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -731,6 +732,27 @@ mod tests { | |||||||
| assert!(!session.notices_since(mark).iter().any(|n| n.text.contains("make room"))); | ||||||||
| } | ||||||||
|
|
||||||||
| /// Undo and Redo copy no rows and aren't checked (they are registered as `.view()`, so they | ||||||||
| /// don't count as edits): they run when even one copy of the active layer doesn't fit, as the | ||||||||
| /// way back from an edit (#2431). | ||||||||
| #[test] | ||||||||
| fn undo_and_redo_run_when_an_edit_would_not_fit() { | ||||||||
| let mut session = session(4096); | ||||||||
| session.undo_memory.limit = 1 << 30; | ||||||||
| session.undo_memory.memory = None; | ||||||||
| for text in ["b", "c"] { | ||||||||
| edit(&mut session, &text.repeat(4096)); | ||||||||
| } | ||||||||
| session.active_layer = Some(session.map().layer_by_name("rows").unwrap().id); | ||||||||
| session.undo_memory.memory = Some(4); | ||||||||
| assert!(session.run("edit.setValue", &json!({"layer": "rows", "row": 0, "field": "text", "value": "d"})).is_err()); | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test coverage (confidence ~80%). This assertion only checks that the edit fails. It does not check why, so the premise of the test ("the edit would not fit even with no history") is unverified: an unrelated error, such as a wrong layer or field, would also pass. The neighbouring tests at lines 683-684 and 727-730 check the message. Suggested change:
Suggested change
|
||||||||
| session.run("edit.undo", &json!({})).unwrap(); | ||||||||
| assert_eq!(value(&session), &Value::Text("b".repeat(4096))); | ||||||||
| session.run("edit.redo", &json!({})).unwrap(); | ||||||||
| assert_eq!(value(&session), &Value::Text("c".repeat(4096))); | ||||||||
| assert_eq!((session.undo_depth(), session.can_redo()), (2, false)); | ||||||||
| } | ||||||||
|
|
||||||||
| #[test] | ||||||||
| fn paste_special_is_not_measured_by_the_active_layer() { | ||||||||
| let mut session = session(4096); | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AGENTS.md (confidence ~45%, a judgment call for maintainers). AGENTS.md says a loss gets "one notice per kind with a count". This arm says the drop again on every occurrence (the PR body says so on purpose, as it is rare). The earlier
say_room()gate limits the make-room notice to once a project, so this arm is now the only path that can repeat a notice of the same kind. Either keep the per-occurrence notice and say so in the PR's Suggested AGENTS.md additions, or gate it the same way. The message text and the(N Undo or Redo steps)count look right: the foreground path always passesin_place = true, so this arm is only reached from the background and reclaim paths where history moved on.