From b1daa98126b364c189d21a68ec32683a21848e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 19 Aug 2026 16:33:31 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(timeline):=20a=20grouped=20c?= =?UTF-8?q?lip=20is=20a=20whole=20take=20from=20any=20lane?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.rs | 65 +++++++++++++++++++++++++++++++-- crates/app/src/timeline_math.rs | 27 ++++++++++---- 2 files changed, 81 insertions(+), 11 deletions(-) diff --git a/crates/app/src/tests/editing.rs b/crates/app/src/tests/editing.rs index eda76b8..d305fc9 100644 --- a/crates/app/src/tests/editing.rs +++ b/crates/app/src/tests/editing.rs @@ -1757,10 +1757,13 @@ fn a_track_can_be_added_dropped_on_edited_and_taken_back() { for lane in back.lanes() { assert_eq!(back.lane_clips(lane), session.lane_clips(lane), "{lane:?}"); } - // Delete on the layer is a lift: it is laid over the timeline, so - // closing a hole under it would drag the take beneath out of step with - // it. The take on the first pair is still a take, and still ripples. - assert!(!whole_take(&session, v2, 0)); + // The drop grouped `V2` with the `A2` it added -- a take, same as the + // first pair's, just on an added row -- so Delete would close both their + // own lanes too (`Project::delete_members`), not drag the first pair out + // of step: `delete_members` ripples only a member's own lane. Lift is + // tested directly here instead, to check its own hole-left-open law + // without going through the Delete key's routing. + assert!(whole_take(&session, v2, 0)); assert!(whole_take(&session, Lane::V1, 0)); assert!(whole_take(&session, Lane::A1, 0)); assert_eq!(a2.label(), "A2"); @@ -1797,6 +1800,60 @@ fn a_track_can_be_added_dropped_on_edited_and_taken_back() { assert_eq!(format_refusal(&session, Format::Mp4), None); } +/// A caption grouped with a clip on an *added* lane closes its lane's hole +/// too, not just the first pair's: the same law commit `cdc53a6` gave `V1` +/// (`whole_take` -> `Project::delete_members`) has to hold from every anchor +/// a Delete can be clicked from, or a grouped caption on `V2`/subtitle +/// survives its clip as an orphan link. `whole_take` used to answer `false` +/// for any lane with `ord >= 1` no matter what it was grouped with, which +/// routed `Player::delete_selected` to `lift_clip` -- the clip's own lane +/// left a hole, and the caption it was grouped with was never touched at +/// all. +#[test] +fn a_grouped_clip_on_an_added_lane_closes_its_hole_with_its_caption() { + use engine::project::LaneKind; + + let (mut session, sub_lane) = with_subtitle_lane(); + let v2 = session.add_lane(LaneKind::Video); + let path = session.sources()[0].path.clone(); + assert!( + session + .place_stream_at(0.0, &path, 0, Some(v2)) + .expect("its own file is on this timeline") + ); + session + .place_sub(sub_lane, 0, one_second(0)) + .expect("the caption goes down"); + session + .group_all(&[(v2, 0), (sub_lane, 0)]) + .expect("a clip on an added lane and a caption are a group"); + + // The group pairs the clip for the whole-take question from its own + // lane, `ord >= 1` or not. + assert!(whole_take(&session, v2, 0)); + + // Two clips after the group's own -- something to close the hole + // against on the caption's lane too. + session + .place_sub(sub_lane, 60, one_second(60)) + .expect("a second caption after it"); + assert_eq!(session.sub_lane(sub_lane).len(), 2); + + // `Player::delete_selected` calls exactly this door once `whole_take` + // says yes -- the fix is that it now reaches it from `v2` too. + assert!(session.delete_clip(v2, 0)); + assert!(session.lane_clips(v2).is_empty(), "the clip is gone"); + assert_eq!( + session.sub_lane(sub_lane).len(), + 1, + "its grouped caption went with it, not left as an orphan" + ); + assert_eq!( + session.sub_lane(sub_lane)[0].start, 30, + "and the hole under it closed: the caption after it slid up" + ); +} + #[test] fn a_source_is_only_ever_asked_for_its_peaks_once() { let (a, b) = (asset("test_av.mp4"), asset("test_av2.mp4")); diff --git a/crates/app/src/timeline_math.rs b/crates/app/src/timeline_math.rs index 45b7f45..85efc18 100644 --- a/crates/app/src/timeline_math.rs +++ b/crates/app/src/timeline_math.rs @@ -6,12 +6,17 @@ use crate::*; /// hole under it: a take is what the first pair of lanes carries between them, /// `V1`'s picture and the sound grouped with it, and dropping one moves the /// frames after it on every lane. A caption a hand grouped with the clip -/// counts as its partner too: the group is what pairs, not the lane's kind. +/// counts as its partner too: the group is what pairs, not the lane's kind -- +/// and a group answers `true` from *whichever* member's lane the question is +/// asked from, added row or not, because a grouped delete +/// ([`PlaybackSession::delete_clip`] -> `Project::delete_members`) closes +/// every member's own lane by its own span already, not just the first pair's. /// /// Everything else is a half or a layer, and is *lifted* instead: a half whose -/// picture was lifted (what a lift leaves behind) has no take to ripple, and a -/// clip on a further lane is laid over the timeline rather than part of it -- -/// closing a hole under it would drag the take beneath out of step with it. +/// picture was lifted (what a lift leaves behind) has no take to ripple, and an +/// *ungrouped* clip on a further lane is laid over the timeline rather than +/// part of it -- closing a hole under it would drag the take beneath out of +/// step with it. pub(crate) fn whole_take(session: &PlaybackSession, lane: Lane, idx: usize) -> bool { let Some(clip) = session.lane_clips(lane).get(idx) else { return false; @@ -29,6 +34,12 @@ pub(crate) fn whole_take(session: &PlaybackSession, lane: Lane, idx: usize) -> b .any(|link| link.is_some() && link == clip.link) }; match (lane.kind, lane.ord) { + // A clip a hand grouped closes its own lane wherever it sits: + // `Project::delete_members` already cuts every member's own span out + // of its own lane, whichever lanes those are -- so a caption or clip + // grouped onto an added row closes its hole exactly as `V1`/`A1`'s + // first pair does, not just the pair itself. + _ if paired() => true, (_, 1..) => false, // The picture of a take -- unless the take has been taken apart: a // 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 // under it would drag away the very half it was detached from. A clip in // no group at all is not a half but a placement, and on `V1` a placement // is the take there is. - (LaneKind::Video, _) => clip.link.is_none() || paired(), + (LaneKind::Video, _) => clip.link.is_none(), // The sound of a take, only while the take is still there: its group is - // carried by a clip on some other lane. - (LaneKind::Audio, _) => paired(), + // carried by a clip on some other lane. Reached only when `paired()` is + // already false, so this is always false -- kept as its own arm for the + // reason a lone `A1` clip is not a take, not because it does the work. + (LaneKind::Audio, _) => false, // A subtitle lane carries no `Clip` at all, so the lookup above already // returned: never a take, and never rippled as one. (LaneKind::Subtitle, _) => false,