The equalizer commit arms on the curve having moved
Browse files at this commita5f4c04283ba4577fac800872e16dd44203698c7Parent: 5d1e7d9- fix
- the equalizer commit arms on the curve having moved
2 changed files +49 -2
crates/app/src/player/cards.rsmodified+16 -2
| @@ -1542,8 +1542,22 @@ impl Player { | |||
| 1542 | }; | 1542 | }; |
| 1543 | let params = (!self.eq_params.is_identity()).then(|| self.eq_params.clone()); | 1543 | let params = (!self.eq_params.is_identity()).then(|| self.eq_params.clone()); |
| 1544 | if let Some(session) = &mut self.session { | 1544 | if let Some(session) = &mut self.session { |
| 1545 | - session.set_eq(lane, idx, params); | 1545 | + // `set_eq` answers "the index was there and the curve is finite" |
| 1546 | - self.mark_dirty(); | 1546 | + // -- it snapshots and rewrites the very slot it already holds for |
| 1547 | + // a curve that is already in force -- so on its own bool a | ||
| 1548 | + // re-commit of the same curve armed autosave, the ledger's | ||
| 1549 | + // `unsaved` ghost and the close prompt over a project whose bytes | ||
| 1550 | + // had not moved. The arm rides the curve having moved, the | ||
| 1551 | + // comparison `apply_fit` reads for `set_fit` | ||
| 1552 | + // ([`Player::apply_fit`]), and then the door's own answer. | ||
| 1553 | + let moved = session.eq_of(lane, idx).cloned() != params; | ||
| 1554 | + if moved && session.set_eq(lane, idx, params) { | ||
| 1555 | + self.mark_dirty(); | ||
| 1556 | + // `set_eq` reseeks inside the engine -- that is what makes the | ||
| 1557 | + // change audible at once -- and a reseek is what these flags | ||
| 1558 | + // are about. Nothing was written, so nothing was reseeked. | ||
| 1559 | + self.reset_after_reseek(); | ||
| 1560 | + } | ||
| 1547 | } | 1561 | } |
| 1548 | cx.notify(); | 1562 | cx.notify(); |
| 1549 | } | 1563 | } |
crates/app/src/tests/cards.rsmodified+33 -0
| @@ -1739,6 +1739,39 @@ fn every_click_door_that_writes_the_project_arms_autosave() { | |||
| 1739 | "nudge_mix still arms ahead of the door, so a clamped no-op nudge \ | 1739 | "nudge_mix still arms ahead of the door, so a clamped no-op nudge \ |
| 1740 | leaves the project looking edited" | 1740 | leaves the project looking edited" |
| 1741 | ); | 1741 | ); |
| 1742 | + // The equalizer card's commit, the same rule against a door whose bool is | ||
| 1743 | + // the WEAKER of the two shapes: `set_eq` answers "the index was there and | ||
| 1744 | + // the curve is finite" and rewrites the very slot it already holds for a | ||
| 1745 | + // curve already in force, so the arm needs the comparison too -- the same | ||
| 1746 | + // pair of conditions `apply_fit` rides. | ||
| 1747 | + let body = fn_body("commit_eq"); | ||
| 1748 | + let arm = body | ||
| 1749 | + .split_once("if moved && session.set_eq(lane, idx, params) {") | ||
| 1750 | + .expect("the EQ commit no longer rides the curve having moved and then the door") | ||
| 1751 | + .1; | ||
| 1752 | + assert!( | ||
| 1753 | + arm.contains("mark_dirty()"), | ||
| 1754 | + "commit_eq arms outside its gate, so re-committing the curve already \ | ||
| 1755 | + in force would dirty the project" | ||
| 1756 | + ); | ||
| 1757 | + assert!( | ||
| 1758 | + body.contains("session.eq_of(lane, idx).cloned() != params"), | ||
| 1759 | + "commit_eq rides the engine's bool alone, which is true for a \ | ||
| 1760 | + re-commit of the curve already in force" | ||
| 1761 | + ); | ||
| 1762 | + // ...and the reseek bookkeeping rides with the arm, not instead of it. | ||
| 1763 | + assert!( | ||
| 1764 | + arm.contains("reset_after_reseek()"), | ||
| 1765 | + "commit_eq's reseek flags no longer clear on a write that took" | ||
| 1766 | + ); | ||
| 1767 | + let before = body | ||
| 1768 | + .split_once("if moved && session.set_eq(lane, idx, params) {") | ||
| 1769 | + .unwrap() | ||
| 1770 | + .0; | ||
| 1771 | + assert!( | ||
| 1772 | + !before.contains("mark_dirty()"), | ||
| 1773 | + "commit_eq still arms ahead of the door" | ||
| 1774 | + ); | ||
| 1742 | } | 1775 | } |
| 1743 | 1776 | ||
| 1744 | /// The transition doors, which are the class's other shape: both engine | 1777 | /// The transition doors, which are the class's other shape: both engine |