forge
Explore
Log in

Don't you dare go Hollow

Every edit door arms the flag only when it wrote

Browse files at this commit

f7e750cdfb13af3cfb530bfc4d11187b28b2c604Ahmet Kaan GümüşParent: e063ed4
  • fix
    • every edit door arms the flag only when it wrote
Show full message
🐛 fix(autosave): every edit door arms the flag only when it wrote

Eight doors armed `mark_dirty()` before the call that decides whether anything happened, so a stroke that changed nothing -- a clip let go where it was picked up, a caption dragged back to its own frame or dropped on an overlap ("NOT PLACED"), one that is not there any more ("NOTHING LIFTED"), a trim, a fade or a `[`/`]` nudge released against the wall the edge already stood on -- still armed autosave, the ledger's `unsaved` ghost and `Player::close_needs_answer`: a window nobody had touched asked to be saved, and an autosave sidecar was written for it.

Each arm now rides the door's own answer, or the one reading the door's answer cannot give: a caption's own window before and after the trim, and the ramp's own value before and after the fade (`Project::trim_sub` answers `Ok` and `set_fade_*` answers `true` for an edge or a handle that never moved). The history pair left the action table's early arm for its own, since `^z` with an empty history is not a stroke that earned an autosave -- and `Player::undo`/`redo` now clear the selection only alongside the step they took, the same rule the refused split above is held to.
crates/app/src/player/actions.rsmodified+43 -12
@@ -36,6 +36,12 @@ impl Player {
3636 // costs nothing a real edit would not have earned anyway, and one list
3737 // here is the whole answer instead of fifteen scattered calls.
3838 //
39+ // The two exceptions are the history pair, whose doors answer "there was
40+ // a step to take" and are gated in their own arms below: `^z` with
41+ // nothing to undo is not a stroke that earned an autosave, and the
42+ // save-on-close question over a project nobody has touched is exactly
43+ // what the card doors' own gate exists to prevent.
44+ //
3945 // This list is the *action* doors only, and that is the class to mind
4046 // when adding an edit: a control that reaches the session from a
4147 // *click* -- the Clip tab's look chips and wheel, the settings rows,
@@ -54,8 +60,6 @@ impl Player {
5460 | ActionId::Group
5561 | ActionId::Delete
5662 | ActionId::Lift
57- | ActionId::Undo
58- | ActionId::Redo
5963 | ActionId::AddVideoLane
6064 | ActionId::RemoveVideoLane
6165 | ActionId::AddAudioLane
@@ -130,8 +134,16 @@ impl Player {
130134 ActionId::ZoomIn => self.zoom(ZOOM_STEP, None, cx),
131135 ActionId::ZoomOut => self.zoom(1. / ZOOM_STEP, None, cx),
132136 ActionId::ZoomFit => self.zoom_fit(cx),
133- ActionId::Undo => self.undo(cx),
134- ActionId::Redo => self.redo(cx),
137+ ActionId::Undo => {
138+ if self.undo(cx) {
139+ self.mark_dirty();
140+ }
141+ }
142+ ActionId::Redo => {
143+ if self.redo(cx) {
144+ self.mark_dirty();
145+ }
146+ }
135147 ActionId::AddVideoLane => self.add_lane(LaneKind::Video, cx),
136148 ActionId::AddAudioLane => self.add_lane(LaneKind::Audio, cx),
137149 // The last track of that kind: the one the add key put there, so the
@@ -611,12 +623,17 @@ impl Player {
611623 return;
612624 };
613625 let to = nudge_edge(current, dir, lo, hi);
614- self.mark_dirty();
615626 let trimmed = self
616627 .session
617628 .as_mut()
618629 .is_some_and(|s| s.trim_clip(lane, idx, edge, to));
619630 if trimmed {
631+ // The arm rides the door's own answer: `trim_clip` is `false` for an
632+ // edge already where it was asked to go -- the `[`/`]` pressed
633+ // against the wall the edge is already on -- so the flag, the
634+ // autosave sidecar and the save-on-close question stay off a
635+ // project nobody has changed.
636+ self.mark_dirty();
620637 self.reset_after_reseek();
621638 // Loop-trim follows the edge it is trimming: the whole point of
622639 // the mode is hearing the cut as it moves.
@@ -643,12 +660,15 @@ impl Player {
643660 return;
644661 };
645662 let to = frame_at(session.now(), self.fps);
646- self.mark_dirty();
647663 let trimmed = self
648664 .session
649665 .as_mut()
650666 .is_some_and(|s| s.trim_clip(lane, idx, edge, to));
651667 if trimmed {
668+ // The door's own answer again: an edge the playhead is already on is
669+ // `false`, no undo step, and nothing for the unsaved ghost to be
670+ // about.
671+ self.mark_dirty();
652672 self.reset_after_reseek();
653673 // Loop-trim follows the edge it is trimming, same as the nudge
654674 // pair above.
@@ -684,20 +704,31 @@ impl Player {
684704 cx.notify();
685705 }
686706
687- pub(crate) fn undo(&mut self, cx: &mut Context<Self>) {
688- if self.session.as_mut().is_some_and(PlaybackSession::undo) {
707+ /// Whether there was a step to take, for the reason the action table arms
708+ /// nothing on its own: a `^z` with an empty history is not an edit, and it
709+ /// may not raise the save-on-close question over a project nobody has
710+ /// touched. The selection goes with the step for the same reason it used to
711+ /// go every time: a step back puts the indices on different clips, while a
712+ /// refused one leaves them naming exactly what they named.
713+ pub(crate) fn undo(&mut self, cx: &mut Context<Self>) -> bool {
714+ let stepped = self.session.as_mut().is_some_and(PlaybackSession::undo);
715+ if stepped {
689716 self.reset_after_reseek();
717+ self.selected.clear();
690718 }
691- self.selected.clear();
692719 cx.notify();
720+ stepped
693721 }
694722
695- pub(crate) fn redo(&mut self, cx: &mut Context<Self>) {
696- if self.session.as_mut().is_some_and(PlaybackSession::redo) {
723+ /// [`Player::undo`]'s twin, the same answer and the same gate.
724+ pub(crate) fn redo(&mut self, cx: &mut Context<Self>) -> bool {
725+ let stepped = self.session.as_mut().is_some_and(PlaybackSession::redo);
726+ if stepped {
697727 self.reset_after_reseek();
728+ self.selected.clear();
698729 }
699- self.selected.clear();
700730 cx.notify();
731+ stepped
701732 }
702733 }
703734
crates/app/src/player/timeline_edit.rsmodified+101 -8
@@ -350,7 +350,6 @@ impl Player {
350350 if self.exporting().is_some() {
351351 return;
352352 }
353- self.mark_dirty();
354353 let (Some((start, _)), Some(was)) = (
355354 self.drop_frame(from, idx, x),
356355 self.session
@@ -385,6 +384,14 @@ impl Player {
385384 };
386385 match moved {
387386 true => {
387+ // The arm rides the door's own answer: `move_clip_to` /
388+ // `move_selection_to` answer `false` for a clip let go where it
389+ // was picked up (`Project::move_selection` refuses before its
390+ // snapshot) and for a lane of the wrong kind, and the arms below
391+ // say both in words. Armed before the call it dirtied a project
392+ // nobody had touched -- the ledger's `unsaved` ghost and the
393+ // save-on-close question over an unchanged file.
394+ self.mark_dirty();
388395 // Every pick named a `(lane, ...)` by index into that lane's
389396 // clips, sorted by start -- exactly what an insert or a lane
390397 // change reorders. Re-read by the frame each pick's clip now
@@ -512,7 +519,6 @@ impl Player {
512519 if self.exporting().is_some() {
513520 return;
514521 }
515- self.mark_dirty();
516522 self.snap_cue = None;
517523 self.ghost.clear();
518524 let at = self.place_frame(x).0;
@@ -533,6 +539,15 @@ impl Player {
533539 (None, Some(_)) => Some("NOT PLACED — that subtitle track has no cues".to_string()),
534540 (_, None) => Some("NOT PLACED — no file open".to_string()),
535541 };
542+ // The arm rides the door's own answer: `text` is `None` exactly when
543+ // `Project::place_sub` took the track, and every refusal -- an overlap,
544+ // a lane that is not a subtitle lane, "no file open", "no cues" --
545+ // leaves the project byte-for-byte what it was. Armed ahead of the
546+ // answer it wrote an autosave sidecar, the ledger's `unsaved` ghost and
547+ // the save-on-close question over a project nobody had changed.
548+ if text.is_none() {
549+ self.mark_dirty();
550+ }
536551 match (text, marked) {
537552 (Some(text), _) => self.notify_user(text.into()),
538553 // It went down, and a lane holds its captions in start order
@@ -597,12 +612,19 @@ impl Player {
597612 if self.exporting().is_some() {
598613 return;
599614 }
600- self.mark_dirty();
601615 self.snap_cue = None;
602616 self.ghost.clear();
603617 let Some(idx) = self.dragged_sub(drag) else {
604618 return;
605619 };
620+ // Where the caption stands *now*, so the arm below can tell a move from
621+ // a drag let go where it began: `Project::move_sub` answers `Ok` for a
622+ // pick-up-put-back too ("`Ok`, and no undo step, because nothing
623+ // changed"), so its own answer is not a change report.
624+ let was = self
625+ .session
626+ .as_ref()
627+ .and_then(|session| session.sub_lane(drag.lane).get(idx).map(|sub| sub.start));
606628 // Asked before the edit, on the indices the press captured: the
607629 // engine's own grouped-with-clips answer, which is exactly when its
608630 // move reseeks -- a caption grouped only with other captions moves no
@@ -640,6 +662,20 @@ impl Player {
640662 .as_ref()
641663 .and_then(|session| sub_mark(session.sub_lane(to), start))
642664 .map(|i| (to, i));
665+ // The arm rides the caption's own place having moved -- the
666+ // engine's `Ok` covers the put-back that takes no undo step at
667+ // all (`Project::move_sub`), and a project nobody has touched
668+ // must not light the `unsaved` ghost.
669+ let landed = mark.and_then(|(lane, i)| {
670+ self.session
671+ .as_ref()?
672+ .sub_lane(lane)
673+ .get(i)
674+ .map(|sub| (lane, sub.start))
675+ });
676+ if landed != was.map(|start| (drag.lane, start)) {
677+ self.mark_dirty();
678+ }
643679 self.selected = match mark {
644680 Some(mark) => {
645681 let mut sel = Selection::new();
@@ -670,7 +706,6 @@ impl Player {
670706 if self.exporting().is_some() {
671707 return;
672708 }
673- self.mark_dirty();
674709 let lifted = self
675710 .session
676711 .as_mut()
@@ -683,6 +718,11 @@ impl Player {
683718 false => "NOTHING LIFTED — that caption is not there any more".to_string(),
684719 };
685720 if lifted {
721+ // The arm rides the door's own answer: `false` is "NOTHING LIFTED —
722+ // that caption is not there any more", and the project is exactly
723+ // what it was, so the flag, the autosave sidecar and the
724+ // save-on-close question must stay off it.
725+ self.mark_dirty();
686726 // Everything after it on that lane slid down one ([`Vec::remove`]),
687727 // so a mark or an open menu left at or past it names a *different*
688728 // caption now -- and the next Delete would take that one. Both go
@@ -1537,7 +1577,11 @@ impl Player {
15371577 let Some(trim) = self.trim.take() else {
15381578 return;
15391579 };
1540- self.mark_dirty();
1580+ // The arm rides each door's own answer or the caption's own edges --
1581+ // never the call: a trim released where the edge already stood is
1582+ // `Ok`/`true` with no undo step, and it must not leave the project
1583+ // looking edited to autosave, the `unsaved` ghost or the close
1584+ // question.
15411585 // A caption's edge reaches the engine through its own door, at this
15421586 // timeline's rate. An `Ok` is *not* "something changed" -- an edge that
15431587 // stopped at a wall it already stood against is `Ok` with no undo step
@@ -1552,14 +1596,33 @@ impl Player {
15521596 .session
15531597 .as_ref()
15541598 .is_some_and(|session| session.caption_grouped_with_clips(trim.lane, trim.idx));
1599+ // The caption's own window, before and after: the only reading that
1600+ // can tell a trim from an edge released against the wall it already
1601+ // stood on.
1602+ let edges = |player: &Self| {
1603+ player.session.as_ref().and_then(|session| {
1604+ session
1605+ .sub_lane(trim.lane)
1606+ .get(trim.idx)
1607+ .map(|sub| (sub.start, sub.frames, sub.in_us, sub.out_us))
1608+ })
1609+ };
1610+ let before = edges(self);
15551611 let trimmed = self
15561612 .session
15571613 .as_mut()
15581614 .map(|session| session.trim_sub(trim.lane, trim.idx, trim.edge, trim.to));
15591615 match trimmed {
15601616 Some(Err(e)) => self.notify_user(format!("NOT TRIMMED — {e}").into()),
1561- Some(Ok(())) if grouped => self.reset_after_reseek(),
1562- _ => {}
1617+ Some(Ok(())) => {
1618+ if edges(self) != before {
1619+ self.mark_dirty();
1620+ }
1621+ if grouped {
1622+ self.reset_after_reseek();
1623+ }
1624+ }
1625+ None => {}
15631626 }
15641627 cx.notify();
15651628 return;
@@ -1569,6 +1632,10 @@ impl Player {
15691632 .as_mut()
15701633 .is_some_and(|session| session.trim_clip(trim.lane, trim.idx, trim.edge, trim.to));
15711634 if trimmed {
1635+ // The arm rides the door's own answer: `trim_clip` is `false` for an
1636+ // edge already where it was asked to go, which is no undo step and
1637+ // no edit.
1638+ self.mark_dirty();
15721639 self.reset_after_reseek();
15731640 }
15741641 cx.notify();
@@ -1643,7 +1710,20 @@ impl Player {
16431710 let Some(fade) = self.fade_drag.take() else {
16441711 return;
16451712 };
1646- self.mark_dirty();
1713+ // The ramp the clip is carrying *now*, so the arm below can tell a drag
1714+ // from a press-and-release that left the handle where it was: `set_fade_in`
1715+ // / `set_fade_out` answer `true` for any index that exists and take an
1716+ // undo step either way, so their own answer is not a change report.
1717+ let was = match fade.is_in {
1718+ true => self
1719+ .session
1720+ .as_ref()
1721+ .map(|session| session.fade_in_of(fade.lane, fade.idx)),
1722+ false => self
1723+ .session
1724+ .as_ref()
1725+ .map(|session| session.fade_out_of(fade.lane, fade.idx)),
1726+ };
16471727 let set = self
16481728 .session
16491729 .as_mut()
@@ -1652,6 +1732,19 @@ impl Player {
16521732 false => session.set_fade_out(fade.lane, fade.idx, fade.to),
16531733 });
16541734 if set {
1735+ let now = match fade.is_in {
1736+ true => self
1737+ .session
1738+ .as_ref()
1739+ .map(|session| session.fade_in_of(fade.lane, fade.idx)),
1740+ false => self
1741+ .session
1742+ .as_ref()
1743+ .map(|session| session.fade_out_of(fade.lane, fade.idx)),
1744+ };
1745+ if now != was {
1746+ self.mark_dirty();
1747+ }
16551748 cx.notify();
16561749 }
16571750 }
crates/app/src/tests/cards.rsmodified+151 -24
@@ -914,7 +914,10 @@ fn the_budget_is_the_one_number_the_engine_gets() {
914914 // put on screen.
915915 assert_eq!(auto_bps(1920, 1080, 30.), 6_220_800);
916916 assert_eq!(auto_bps(160, 120, 15.), BPS_MIN, "a tiny picture floors");
917- assert!(auto_bps(7680, 4320, 60.) <= 20_000_000, "and a huge one caps");
917+ assert!(
918+ auto_bps(7680, 4320, 60.) <= 20_000_000,
919+ "and a huge one caps"
920+ );
918921 for bps in [auto_bps(1920, 1080, 30.), auto_bps(320, 240, 24.)] {
919922 assert!((BPS_MIN..=BPS_MAX).contains(&bps));
920923 }
@@ -1067,11 +1070,25 @@ fn a_chord_the_export_moment_answers_never_reaches_the_room() {
10671070 let (typing, closed) = rest
10681071 .split_once("return true;")
10691072 .expect("the typing branch returns before the chords below it");
1070- assert!(typing.contains("self.budget_edit = None"), "esc leaves the field");
1071- assert!(closed.contains("self.close_card()"), "then esc closes the moment");
1073+ assert!(
1074+ typing.contains("self.budget_edit = None"),
1075+ "esc leaves the field"
1076+ );
1077+ assert!(
1078+ closed.contains("self.close_card()"),
1079+ "then esc closes the moment"
1080+ );
10721081 // Its chords, all of them consumed here rather than by the keymap.
10731082 for chord in [
1074- "\"d\"", "\"n\"", "\"e\"", "\"enter\"", "\"up\"", "\"down\"", "\"c\"", "\"b\"", "\"g\"",
1083+ "\"d\"",
1084+ "\"n\"",
1085+ "\"e\"",
1086+ "\"enter\"",
1087+ "\"up\"",
1088+ "\"down\"",
1089+ "\"c\"",
1090+ "\"b\"",
1091+ "\"g\"",
10751092 "\",\"",
10761093 ] {
10771094 assert!(closed.contains(chord), "{chord} is not the moment's own");
@@ -1086,7 +1103,11 @@ fn a_chord_the_export_moment_answers_never_reaches_the_room() {
10861103 fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
10871104 let cards = src_text("ui/cards.rs");
10881105 let start = cards.find("fn export_card(").expect("the moment");
1089- let body = &cards[start..start + cards[start..].find("\n /// ").unwrap_or(cards.len() - start)];
1106+ let body = &cards[start
1107+ ..start
1108+ + cards[start..]
1109+ .find("\n /// ")
1110+ .unwrap_or(cards.len() - start)];
10901111 // A segment is the setter it names, not a readout of it.
10911112 for (id, chord, setter) in [
10921113 ("moment-picture", "\"c\"", "cycle_export_picture"),
@@ -1098,7 +1119,10 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
10981119 assert!(body.contains(setter), "the {id} segment changes nothing");
10991120 }
11001121 // The door, wearing the room's own chord rather than a hand-typed one.
1101- assert!(body.contains("moment-settings"), "row 3 has no settings door");
1122+ assert!(
1123+ body.contains("moment-settings"),
1124+ "row 3 has no settings door"
1125+ );
11021126 assert!(
11031127 body.contains("self.keymap.chord(ActionId::Settings)"),
11041128 "the door's chord is not read from the keymap"
@@ -1113,7 +1137,10 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
11131137 .map(|at| &cards[at..at + 1900])
11141138 .expect("the segment atom");
11151139 assert!(seg.contains("INK3()") && seg.contains("INK4()"));
1116- assert!(seg.contains("DARK_RAISED()"), "a segment does not answer hover");
1140+ assert!(
1141+ seg.contains("DARK_RAISED()"),
1142+ "a segment does not answer hover"
1143+ );
11171144 // The readouts worth seeing: the project's picture size and rate, and
11181145 // a sound rate that is on the line whether or not it is pressable.
11191146 assert!(
@@ -1126,13 +1153,18 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
11261153 );
11271154 // The picture segment is a child, not a `has_video` maybe: hidden on the
11281155 // sound-only formats it left `c` pressing nothing and no way back.
1129- let at = body.find("\"moment-picture\"").expect("the picture segment");
1156+ let at = body
1157+ .find("\"moment-picture\"")
1158+ .expect("the picture segment");
11301159 assert!(
11311160 !body[at - 240..at].contains("has_video"),
11321161 "the picture segment is gated on has_video again -- the dead end"
11331162 );
11341163 // Wrapped, never cut: the readouts made row 3 longer than 1280 wide.
1135- assert!(body.contains(".flex_wrap()"), "row 3 truncates instead of wrapping");
1164+ assert!(
1165+ body.contains(".flex_wrap()"),
1166+ "row 3 truncates instead of wrapping"
1167+ );
11361168 }
11371169
11381170 /// The dead end the user hit: the cycle walked into the sound-only formats
@@ -1140,15 +1172,22 @@ fn row_three_wears_the_encode_options_and_the_door_to_the_rest() {
11401172 /// and can't turn it back to video"). One cycle, and it wraps.
11411173 #[test]
11421174 fn the_picture_cycle_wraps_out_of_the_sound_only_formats() {
1143- use crate::ui::settings_stance::{PICTURE_CYCLE, next_picture};
1175+ use crate::ui::settings_stance::{next_picture, PICTURE_CYCLE};
11441176 // Nothing refused: every stop is the next one, and the last wraps to the
11451177 // first -- OGG, the tail of the list, back to MP4.
11461178 let mut at = PICTURE_CYCLE[0];
1147- for &want in PICTURE_CYCLE.iter().skip(1).chain(std::iter::once(&PICTURE_CYCLE[0])) {
1179+ for &want in PICTURE_CYCLE
1180+ .iter()
1181+ .skip(1)
1182+ .chain(std::iter::once(&PICTURE_CYCLE[0]))
1183+ {
11481184 at = next_picture(at, |_| false);
11491185 assert_eq!(at, want, "the cycle stopped walking");
11501186 }
1151- assert_eq!(at, PICTURE_CYCLE[0], "a full walk is a wrap, not a dead end");
1187+ assert_eq!(
1188+ at, PICTURE_CYCLE[0],
1189+ "a full walk is a wrap, not a dead end"
1190+ );
11521191 assert_eq!(next_picture(Format::Ogg, |_| false), Format::Mp4);
11531192 // A timeline with no picture refuses every video format, and the cycle
11541193 // still moves: the sound-only stops are what is left of it.
@@ -1278,12 +1317,18 @@ fn the_moment_and_the_settings_room_wear_the_same_export_chords() {
12781317 assert!(settings.contains(chord), "the EXPORT rows lost {chord}");
12791318 assert!(moment.contains(chord), "row 3 lost {chord}");
12801319 assert!(handler.contains(chord), "the moment answers no {chord}");
1281- assert!(player.contains(chord), "the settings page answers no {chord}");
1320+ assert!(
1321+ player.contains(chord),
1322+ "the settings page answers no {chord}"
1323+ );
12821324 }
12831325 // `e` stays the Export press: the encoder seat took `g` rather than a
12841326 // shifted letter, which no ghost wears.
12851327 assert!(handler.contains("\"e\" | \"enter\" => self.start_export"));
1286- assert!(!settings.contains("\n \"e\","), "the Encoder row took `e` back");
1328+ assert!(
1329+ !settings.contains("\n \"e\","),
1330+ "the Encoder row took `e` back"
1331+ );
12871332 }
12881333
12891334 /// The Sound row: what it offers, and that the pick travels to the engine
@@ -1401,9 +1446,15 @@ fn a_typed_colour_is_read_in_every_spelling_and_anything_else_is_refused() {
14011446 edit.typed('z');
14021447 assert_eq!(edit.commit(), None);
14031448 let why = edit.refusal.clone().expect("a refusal, not a silence");
1404- assert!(why.contains("#RRGGBB"), "the refusal says what a colour is: {why}");
1449+ assert!(
1450+ why.contains("#RRGGBB"),
1451+ "the refusal says what a colour is: {why}"
1452+ );
14051453 assert_eq!(edit.text, "zz", "the refusal keeps the text it refused");
1406- assert!(edit.detail().contains("zz▏"), "the caret stays in the buffer");
1454+ assert!(
1455+ edit.detail().contains("zz▏"),
1456+ "the caret stays in the buffer"
1457+ );
14071458 // ...and the next stroke clears it: that reason described the text that is
14081459 // no longer there.
14091460 edit.typed('0');
@@ -1562,6 +1613,81 @@ fn every_click_door_that_writes_the_project_arms_autosave() {
15621613 "{name} arms outside its gate, so a no-op pick would dirty the project"
15631614 );
15641615 }
1616+ // The drag-and-drop family on the timeline: the same class, and the same
1617+ // rule. Every one of these doors can answer "nothing happened" -- a clip let
1618+ // go where it was picked up, a caption dragged back to the frame it started
1619+ // on, a trim, a fade or a `[`/`]` nudge released against the wall the edge
1620+ // already stood on, a subtitle row dropped on an overlap ("NOT PLACED") or a
1621+ // caption that is not there any more ("NOTHING LIFTED") -- and each one used
1622+ // to arm the flag *before* the door was asked, so the ledger's `unsaved`
1623+ // ghost, the autosave sidecar and the save-on-close question described a
1624+ // project whose content was byte-for-byte what it was.
1625+ //
1626+ // Each arm now rides its own door's answer, or the one reading the door's
1627+ // answer cannot give: a caption's own window before and after the trim
1628+ // (`Project::trim_sub` answers `Ok` for an edge released at a wall it already
1629+ // stood against) and the ramp's own value before and after the fade
1630+ // (`set_fade_*` answer `true` for any index that exists).
1631+ for (name, gate) in [
1632+ ("move_clip", "match moved {"),
1633+ (
1634+ "place_sub",
1635+ "let text = match (self.sub_of_track(track), &mut self.session) {",
1636+ ),
1637+ ("move_sub", "Some(Ok(())) => {"),
1638+ ("lift_sub", "if lifted {"),
1639+ ("commit_trim", "if trim.lane.kind == LaneKind::Subtitle {"),
1640+ ("commit_fade", "if set {"),
1641+ ("nudge_cut", "let to = nudge_edge(current, dir, lo, hi);"),
1642+ (
1643+ "trim_cut_to_playhead",
1644+ "let to = frame_at(session.now(), self.fps);",
1645+ ),
1646+ ] {
1647+ let body = fn_body(name);
1648+ let (before, after) = body
1649+ .split_once(gate)
1650+ .unwrap_or_else(|| panic!("{name} lost the gate its arm rides"));
1651+ assert!(
1652+ after.contains("mark_dirty()"),
1653+ "{name} arms outside its gate, so a stroke that changed nothing \
1654+ would dirty the project"
1655+ );
1656+ assert!(
1657+ !before.contains("mark_dirty()"),
1658+ "{name} still arms ahead of its gate, so a refusal -- or a drag let \
1659+ go where it started -- leaves the project looking edited"
1660+ );
1661+ }
1662+ // The history pair is the one place the action table does not arm early:
1663+ // the door's own answer ("there was a step to take") is the gate, so `^z`
1664+ // with an empty history leaves the flag -- and the close question -- clear.
1665+ let act = fn_body("act");
1666+ for gate in ["if self.undo(cx) {", "if self.redo(cx) {"] {
1667+ let after = act
1668+ .split_once(gate)
1669+ .unwrap_or_else(|| panic!("{gate} is gone from the action table"))
1670+ .1;
1671+ assert!(
1672+ after.contains("mark_dirty()"),
1673+ "the arm behind `{gate}` arms nothing, so a real step back is \
1674+ invisible to autosave, the unsaved ghost and the close question"
1675+ );
1676+ }
1677+ // ...and the answer the arm reads is the door's own: the session's bool, not
1678+ // a bare call that would arm for an undo with nothing to undo.
1679+ for name in ["undo", "redo"] {
1680+ let body = fn_body(name);
1681+ assert!(
1682+ body.contains("PlaybackSession::") && body.contains("stepped"),
1683+ "Player::{name} no longer answers whether there was a step to take"
1684+ );
1685+ assert!(
1686+ !body.contains("mark_dirty"),
1687+ "Player::{name} arms its own flag, so the arm in `act` is a second \
1688+ one for the same step"
1689+ );
1690+ }
15651691 }
15661692
15671693 /// [`crate::ui::dock_stance::transition_of`]: the dock's duration row
@@ -1780,11 +1906,9 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() {
17801906 assert!(native_detail.ends_with(" source"), "{native_detail}");
17811907 // A project at a size nobody listed still gets the whole list, with
17821908 // nothing marked rather than a wrong row marked.
1783- assert!(
1784- resolution_choices((1000, 1000), native)
1785- .iter()
1786- .all(|(.., picked)| !picked)
1787- );
1909+ assert!(resolution_choices((1000, 1000), native)
1910+ .iter()
1911+ .all(|(.., picked)| !picked));
17881912 // Picking a row means that row, and stepping means the next one: the
17891913 // list and the stroke read the same ladder.
17901914 assert_eq!(next_resolution(ladder[1], native), ladder[2]);
@@ -1883,7 +2007,10 @@ fn a_choice_list_offers_every_value_and_fits_the_smallest_window() {
18832007 assert!(tall <= 360., "the list is taller than the floor");
18842008 assert_eq!(
18852009 menu_at(point(px(600.), px(340.)), size(px(640.), px(360.)), tall),
1886- (640. - crate::layout::MENU_EDGE - MENU_W, 360. - crate::layout::MENU_EDGE - tall),
2010+ (
2011+ 640. - crate::layout::MENU_EDGE - MENU_W,
2012+ 360. - crate::layout::MENU_EDGE - tall
2013+ ),
18872014 "the list would hang off the smallest window"
18882015 );
18892016 }
@@ -2238,8 +2365,8 @@ fn maximizing_a_card_grows_its_box_without_moving_where_a_value_sits_in_it() {
22382365 /// inside the dock, or hands it the dock's width again, fails this.
22392366 #[test]
22402367 fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() {
2368+ use crate::layout::{split_size, Split};
22412369 use crate::SPLIT_W;
2242- use crate::layout::{Split, split_size};
22432370
22442371 // `layout::SPLIT_W` is the one divider between `stance-centre` and the
22452372 // dock; the 56px rail that used to eat the centre's left edge is gone
@@ -2286,7 +2413,7 @@ fn a_maximized_cards_room_is_bigger_than_the_docked_rooms_not_smaller() {
22862413 /// assumption.
22872414 #[test]
22882415 fn a_maximized_card_can_never_rise_above_the_picture_no_matter_the_bench_height() {
2289- use crate::ui::stance::{LEDGER_H, TIME_BAND_H, below_picture_floor};
2416+ use crate::ui::stance::{below_picture_floor, LEDGER_H, TIME_BAND_H};
22902417 let viewport_h = 1080.;
22912418 for bench_h in [140., 200., 400.] {
22922419 assert_eq!(