forge
Explore
Log in

Don't you dare go Hollow

A grouped clip is a whole take from any lane

Browse files at this commit

b1daa98126b364c189d21a68ec32683a21848e79Ahmet Kaan GümüşParent: d2ac4e7
  • fix
    • a grouped clip is a whole take from any lane
Show full message
🐛 fix(timeline): a grouped clip is a whole take from any lane

whole_take answered false for any clip on an added row before it ever
asked whether the clip was grouped, so Delete on a grouped clip on
V2/A2 routed to lift_clip and left the group's caption behind with an
orphan link -- the same one-law-from-every-anchor class cdc53a6 closed
on the caption side. The pairing check now comes first; the ord gate
only catches genuinely ungrouped layers, which are still lifted.

One existing test had the bug baked into its assertion
(!whole_take on a grouped V2 take) and now asserts the law instead.
crates/app/src/tests/editing.rsmodified+61 -4
@@ -1757,10 +1757,13 @@ fn a_track_can_be_added_dropped_on_edited_and_taken_back() {
1757 for lane in back.lanes() {1757 for lane in back.lanes() {
1758 assert_eq!(back.lane_clips(lane), session.lane_clips(lane), "{lane:?}");1758 assert_eq!(back.lane_clips(lane), session.lane_clips(lane), "{lane:?}");
1759 }1759 }
1760- // Delete on the layer is a lift: it is laid over the timeline, so1760+ // The drop grouped `V2` with the `A2` it added -- a take, same as the
1761- // closing a hole under it would drag the take beneath out of step with1761+ // first pair's, just on an added row -- so Delete would close both their
1762- // it. The take on the first pair is still a take, and still ripples.1762+ // own lanes too (`Project::delete_members`), not drag the first pair out
1763- assert!(!whole_take(&session, v2, 0));1763+ // of step: `delete_members` ripples only a member's own lane. Lift is
1764+ // tested directly here instead, to check its own hole-left-open law
1765+ // without going through the Delete key's routing.
1766+ assert!(whole_take(&session, v2, 0));
1764 assert!(whole_take(&session, Lane::V1, 0));1767 assert!(whole_take(&session, Lane::V1, 0));
1765 assert!(whole_take(&session, Lane::A1, 0));1768 assert!(whole_take(&session, Lane::A1, 0));
1766 assert_eq!(a2.label(), "A2");1769 assert_eq!(a2.label(), "A2");
@@ -1797,6 +1800,60 @@ fn a_track_can_be_added_dropped_on_edited_and_taken_back() {
1797 assert_eq!(format_refusal(&session, Format::Mp4), None);1800 assert_eq!(format_refusal(&session, Format::Mp4), None);
1798 }1801 }
1799 1802
1803+/// A caption grouped with a clip on an *added* lane closes its lane's hole
1804+/// too, not just the first pair's: the same law commit `cdc53a6` gave `V1`
1805+/// (`whole_take` -> `Project::delete_members`) has to hold from every anchor
1806+/// a Delete can be clicked from, or a grouped caption on `V2`/subtitle
1807+/// survives its clip as an orphan link. `whole_take` used to answer `false`
1808+/// for any lane with `ord >= 1` no matter what it was grouped with, which
1809+/// routed `Player::delete_selected` to `lift_clip` -- the clip's own lane
1810+/// left a hole, and the caption it was grouped with was never touched at
1811+/// all.
1812+#[test]
1813+fn a_grouped_clip_on_an_added_lane_closes_its_hole_with_its_caption() {
1814+ use engine::project::LaneKind;
1815+
1816+ let (mut session, sub_lane) = with_subtitle_lane();
1817+ let v2 = session.add_lane(LaneKind::Video);
1818+ let path = session.sources()[0].path.clone();
1819+ assert!(
1820+ session
1821+ .place_stream_at(0.0, &path, 0, Some(v2))
1822+ .expect("its own file is on this timeline")
1823+ );
1824+ session
1825+ .place_sub(sub_lane, 0, one_second(0))
1826+ .expect("the caption goes down");
1827+ session
1828+ .group_all(&[(v2, 0), (sub_lane, 0)])
1829+ .expect("a clip on an added lane and a caption are a group");
1830+
1831+ // The group pairs the clip for the whole-take question from its own
1832+ // lane, `ord >= 1` or not.
1833+ assert!(whole_take(&session, v2, 0));
1834+
1835+ // Two clips after the group's own -- something to close the hole
1836+ // against on the caption's lane too.
1837+ session
1838+ .place_sub(sub_lane, 60, one_second(60))
1839+ .expect("a second caption after it");
1840+ assert_eq!(session.sub_lane(sub_lane).len(), 2);
1841+
1842+ // `Player::delete_selected` calls exactly this door once `whole_take`
1843+ // says yes -- the fix is that it now reaches it from `v2` too.
1844+ assert!(session.delete_clip(v2, 0));
1845+ assert!(session.lane_clips(v2).is_empty(), "the clip is gone");
1846+ assert_eq!(
1847+ session.sub_lane(sub_lane).len(),
1848+ 1,
1849+ "its grouped caption went with it, not left as an orphan"
1850+ );
1851+ assert_eq!(
1852+ session.sub_lane(sub_lane)[0].start, 30,
1853+ "and the hole under it closed: the caption after it slid up"
1854+ );
1855+}
1856+
1800 #[test]1857 #[test]
1801 fn a_source_is_only_ever_asked_for_its_peaks_once() {1858 fn a_source_is_only_ever_asked_for_its_peaks_once() {
1802 let (a, b) = (asset("test_av.mp4"), asset("test_av2.mp4"));1859 let (a, b) = (asset("test_av.mp4"), asset("test_av2.mp4"));
crates/app/src/timeline_math.rsmodified+20 -7
@@ -6,12 +6,17 @@ use crate::*;
6 /// hole under it: a take is what the first pair of lanes carries between them,6 /// hole under it: a take is what the first pair of lanes carries between them,
7 /// `V1`'s picture and the sound grouped with it, and dropping one moves the7 /// `V1`'s picture and the sound grouped with it, and dropping one moves the
8 /// frames after it on every lane. A caption a hand grouped with the clip8 /// frames after it on every lane. A caption a hand grouped with the clip
9-/// counts as its partner too: the group is what pairs, not the lane's kind.9+/// counts as its partner too: the group is what pairs, not the lane's kind --
10+/// and a group answers `true` from *whichever* member's lane the question is
11+/// asked from, added row or not, because a grouped delete
12+/// ([`PlaybackSession::delete_clip`] -> `Project::delete_members`) closes
13+/// every member's own lane by its own span already, not just the first pair's.
10 ///14 ///
11 /// Everything else is a half or a layer, and is *lifted* instead: a half whose15 /// Everything else is a half or a layer, and is *lifted* instead: a half whose
12-/// picture was lifted (what a lift leaves behind) has no take to ripple, and a16+/// picture was lifted (what a lift leaves behind) has no take to ripple, and an
13-/// clip on a further lane is laid over the timeline rather than part of it --17+/// *ungrouped* clip on a further lane is laid over the timeline rather than
14-/// closing a hole under it would drag the take beneath out of step with it.18+/// part of it -- closing a hole under it would drag the take beneath out of
19+/// step with it.
15 pub(crate) fn whole_take(session: &PlaybackSession, lane: Lane, idx: usize) -> bool {20 pub(crate) fn whole_take(session: &PlaybackSession, lane: Lane, idx: usize) -> bool {
16 let Some(clip) = session.lane_clips(lane).get(idx) else {21 let Some(clip) = session.lane_clips(lane).get(idx) else {
17 return false;22 return false;
@@ -29,6 +34,12 @@ pub(crate) fn whole_take(session: &PlaybackSession, lane: Lane, idx: usize) -> b
29 .any(|link| link.is_some() && link == clip.link)34 .any(|link| link.is_some() && link == clip.link)
30 };35 };
31 match (lane.kind, lane.ord) {36 match (lane.kind, lane.ord) {
37+ // A clip a hand grouped closes its own lane wherever it sits:
38+ // `Project::delete_members` already cuts every member's own span out
39+ // of its own lane, whichever lanes those are -- so a caption or clip
40+ // grouped onto an added row closes its hole exactly as `V1`/`A1`'s
41+ // first pair does, not just the pair itself.
42+ _ if paired() => true,
32 (_, 1..) => false,43 (_, 1..) => false,
33 // The picture of a take -- unless the take has been taken apart: a44 // The picture of a take -- unless the take has been taken apart: a
34 // detached picture (a group id no other lane carries, which is also what45 // detached picture (a group id no other lane carries, which is also what
@@ -36,10 +47,12 @@ pub(crate) fn whole_take(session: &PlaybackSession, lane: Lane, idx: usize) -> b
36 // under it would drag away the very half it was detached from. A clip in47 // under it would drag away the very half it was detached from. A clip in
37 // no group at all is not a half but a placement, and on `V1` a placement48 // no group at all is not a half but a placement, and on `V1` a placement
38 // is the take there is.49 // is the take there is.
39- (LaneKind::Video, _) => clip.link.is_none() || paired(),50+ (LaneKind::Video, _) => clip.link.is_none(),
40 // The sound of a take, only while the take is still there: its group is51 // The sound of a take, only while the take is still there: its group is
41- // carried by a clip on some other lane.52+ // carried by a clip on some other lane. Reached only when `paired()` is
42- (LaneKind::Audio, _) => paired(),53+ // already false, so this is always false -- kept as its own arm for the
54+ // reason a lone `A1` clip is not a take, not because it does the work.
55+ (LaneKind::Audio, _) => false,
43 // A subtitle lane carries no `Clip` at all, so the lookup above already56 // A subtitle lane carries no `Clip` at all, so the lookup above already
44 // returned: never a take, and never rippled as one.57 // returned: never a take, and never rippled as one.
45 (LaneKind::Subtitle, _) => false,58 (LaneKind::Subtitle, _) => false,