forge
Explore
Log in

Don't you dare go Hollow

A refused split keeps the clip in hand

Browse files at this commit

e063ed4897c879ebeda45ae9ea4cd9ce9d683895Ahmet Kaan GümüşParent: 35306fd
  • fix
    • a refused split keeps the clip in hand
Show full message
🐛 fix(timeline): a refused split keeps the clip in hand

`self.selected.clear()` sat after the if/else in `Player::cut`, so `s` on a seam or in a gap -- the engine's own refusal, worded "NOTHING TO SPLIT — the playhead is already on a cut" -- dropped the picked clip anyway: the next Delete, `x` or menu row then acted on nothing until the user picked the clip again. The sibling `Player::regroup` has always cleared inside its own success branch.
crates/app/src/player/timeline_edit.rsmodified+24 -47
@@ -50,12 +50,21 @@ impl Player {
50 // not that.50 // not that.
51 let cut = session.cut_at(f64::from(at) / self.fps);51 let cut = session.cut_at(f64::from(at) / self.fps);
52 if cut {52 if cut {
53+ // Only a split that happened drops the selection: a refusal is
54+ // "NOTHING TO SPLIT", and the clip in hand is still the clip the
55+ // next Delete, `x` or menu acts on -- clearing it there left the
56+ // user with nothing picked and told them nothing about it. A
57+ // real split is the other way round: the cut it leaves makes the
58+ // picked index name a different clip, so the mark has to go.
59+ // [`Player::regroup`] below has always cleared inside its own
60+ // success branch; this is the same rule on the other half of the
61+ // pair.
62+ self.selected.clear();
53 self.notify_user("SPLIT".into());63 self.notify_user("SPLIT".into());
54 } else {64 } else {
55 self.notify_user("NOTHING TO SPLIT — the playhead is already on a cut".into());65 self.notify_user("NOTHING TO SPLIT — the playhead is already on a cut".into());
56 }66 }
57 }67 }
58- self.selected.clear();
59 cx.notify();68 cx.notify();
60 }69 }
61 70
@@ -72,10 +81,7 @@ impl Player {
72 if session.regroup_at(session.now()) {81 if session.regroup_at(session.now()) {
73 self.selected.clear();82 self.selected.clear();
74 } else {83 } else {
75- self.notify_user(84+ self.notify_user("NOTHING TO REGROUP — no cut under the playhead".into());
76- "NOTHING TO REGROUP — no cut under the playhead"
77- .into(),
78- );
79 }85 }
80 }86 }
81 cx.notify();87 cx.notify();
@@ -97,9 +103,7 @@ impl Player {
97 );103 );
98 }104 }
99 }105 }
100- (Some(_), None) => {106+ (Some(_), None) => self.notify_user("NOTHING DETACHED — nothing selected".into()),
101- self.notify_user("NOTHING DETACHED — nothing selected".into())
102- }
103 (None, _) => {}107 (None, _) => {}
104 }108 }
105 cx.notify();109 cx.notify();
@@ -126,9 +130,7 @@ impl Player {
126 // index (a stroke nobody saw) is not a thing to group.130 // index (a stroke nobody saw) is not a thing to group.
127 let picks = self.marks().0;131 let picks = self.marks().0;
128 match (&mut self.session, self.selected.anchor(), picks.len()) {132 match (&mut self.session, self.selected.anchor(), picks.len()) {
129- (_, None, _) => {133+ (_, None, _) => self.notify_user("NOTHING GROUPED — nothing selected".into()),
130- self.notify_user("NOTHING GROUPED — nothing selected".into())
131- }
132 // The hand's group: every pick, one id.134 // The hand's group: every pick, one id.
133 (Some(session), _, 2..) => {135 (Some(session), _, 2..) => {
134 if let Err(e) = session.group_all(&picks) {136 if let Err(e) = session.group_all(&picks) {
@@ -146,10 +148,9 @@ impl Player {
146 self.notify_user(format!("NOT GROUPED — {e}").into());148 self.notify_user(format!("NOT GROUPED — {e}").into());
147 }149 }
148 }150 }
149- None => self.notify_user(151+ None => {
150- "NOTHING TO GROUP WITH — no clip covers these frames"152+ self.notify_user("NOTHING TO GROUP WITH — no clip covers these frames".into())
151- .into(),153+ }
152- ),
153 },154 },
154 (None, ..) => {}155 (None, ..) => {}
155 }156 }
@@ -237,9 +238,7 @@ impl Player {
237 self.notify_user("NOTHING LIFTED — that half is no longer there".into());238 self.notify_user("NOTHING LIFTED — that half is no longer there".into());
238 }239 }
239 }240 }
240- (Some(_), None) => {241+ (Some(_), None) => self.notify_user("NOTHING LIFTED — nothing selected".into()),
241- self.notify_user("NOTHING LIFTED — nothing selected".into())
242- }
243 (None, _) => {}242 (None, _) => {}
244 }243 }
245 cx.notify();244 cx.notify();
@@ -409,11 +408,7 @@ impl Player {
409 // Everything else that could refuse (a clip that is not there)408 // Everything else that could refuse (a clip that is not there)
410 // cannot be dragged.409 // cannot be dragged.
411 false if from.kind != to.kind => self.notify_user(410 false if from.kind != to.kind => self.notify_user(
412- format!(411+ format!("NOT ON {} — a {kind} clip takes a {lanes} lane", to.label()).into(),
413- "NOT ON {} — a {kind} clip takes a {lanes} lane",
414- to.label()
415- )
416- .into(),
417 ),412 ),
418 // Picked up and put back down where it was: a click, and a click413 // Picked up and put back down where it was: a click, and a click
419 // says nothing.414 // says nothing.
@@ -535,10 +530,7 @@ impl Player {
535 },530 },
536 // The row is greyed and says why in the list; here it says why at531 // The row is greyed and says why in the list; here it says why at
537 // the moment somebody tried to use it anyway.532 // the moment somebody tried to use it anyway.
538- (None, Some(_)) => Some(533+ (None, Some(_)) => Some("NOT PLACED — that subtitle track has no cues".to_string()),
539- "NOT PLACED — that subtitle track has no cues"
540- .to_string(),
541- ),
542 (_, None) => Some("NOT PLACED — no file open".to_string()),534 (_, None) => Some("NOT PLACED — no file open".to_string()),
543 };535 };
544 match (text, marked) {536 match (text, marked) {
@@ -1293,12 +1285,7 @@ impl Player {
1293 /// a project can gain, and the one remove that applies to this lane's kind1285 /// a project can gain, and the one remove that applies to this lane's kind
1294 /// ([`oracle::lane_items`]). Nothing is selected -- a head owns no clip --1286 /// ([`oracle::lane_items`]). Nothing is selected -- a head owns no clip --
1295 /// which is [`Player::open_gap_menu`]'s rule on the other empty target.1287 /// which is [`Player::open_gap_menu`]'s rule on the other empty target.
1296- pub(crate) fn open_head_menu(1288+ pub(crate) fn open_head_menu(&mut self, lane: Lane, at: Point<Pixels>, cx: &mut Context<Self>) {
1297- &mut self,
1298- lane: Lane,
1299- at: Point<Pixels>,
1300- cx: &mut Context<Self>,
1301- ) {
1302 if self.modal() || self.session.is_none() {1289 if self.modal() || self.session.is_none() {
1303 return;1290 return;
1304 }1291 }
@@ -1698,19 +1685,14 @@ impl Player {
1698 [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))),1685 [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))),
1699 _ => self.selected.anchor(),1686 _ => self.selected.anchor(),
1700 }) else {1687 }) else {
1701- self.notify_user(1688+ self.notify_user("NOTHING TO CROSSFADE — no audio clip selected".into());
1702- "NOTHING TO CROSSFADE — no audio clip selected".into(),
1703- );
1704 cx.notify();1689 cx.notify();
1705 return;1690 return;
1706 };1691 };
1707 let frames = self.fps.round().max(1.) as u32;1692 let frames = self.fps.round().max(1.) as u32;
1708 if let Some(session) = &mut self.session {1693 if let Some(session) = &mut self.session {
1709 if !session.crossfade(lane, idx, frames) {1694 if !session.crossfade(lane, idx, frames) {
1710- self.notify_user(1695+ self.notify_user("NOTHING TO CROSSFADE — no neighbour end to end".into());
1711- "NOTHING TO CROSSFADE — no neighbour end to end"
1712- .into(),
1713- );
1714 }1696 }
1715 }1697 }
1716 cx.notify();1698 cx.notify();
@@ -1730,9 +1712,7 @@ impl Player {
1730 [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))),1712 [a, b] if a.0 == b.0 && a.1.abs_diff(b.1) == 1 => Some((a.0, a.1.min(b.1))),
1731 _ => self.selected.anchor(),1713 _ => self.selected.anchor(),
1732 }) else {1714 }) else {
1733- self.notify_user(1715+ self.notify_user("NOTHING TO DISSOLVE — no video clip selected".into());
1734- "NOTHING TO DISSOLVE — no video clip selected".into(),
1735- );
1736 cx.notify();1716 cx.notify();
1737 return;1717 return;
1738 };1718 };
@@ -1747,10 +1727,7 @@ impl Player {
1747 self.fps.round().max(1.) as u321727 self.fps.round().max(1.) as u32
1748 };1728 };
1749 if !session.set_transition_out(lane, idx, frames) {1729 if !session.set_transition_out(lane, idx, frames) {
1750- self.notify_user(1730+ self.notify_user("NOTHING TO DISSOLVE — no neighbour end to end".into());
1751- "NOTHING TO DISSOLVE — no neighbour end to end"
1752- .into(),
1753- );
1754 } else if removing {1731 } else if removing {
1755 self.notify_user("DISSOLVE REMOVED — the clips cut again".into());1732 self.notify_user("DISSOLVE REMOVED — the clips cut again".into());
1756 }1733 }
crates/app/src/tests/editing.rsmodified+100 -80
@@ -109,11 +109,9 @@ fn a_song_opens_the_window_by_itself() {
109 // ...and it places, on the audio lane, through the door `insert_source`109 // ...and it places, on the audio lane, through the door `insert_source`
110 // uses: a second copy of the song at the playhead.110 // uses: a second copy of the song at the playhead.
111 session.seek(1.0);111 session.seek(1.0);
112- assert!(112+ assert!(session
113- session
114 .place_stream_at(1.0, &path, 0, Some(Lane::A1))113 .place_stream_at(1.0, &path, 0, Some(Lane::A1))
115- .expect("its own file is on this timeline")114+ .expect("its own file is on this timeline"));
116- );
117 assert_eq!(session.lane_clips(Lane::A1).len(), 2);115 assert_eq!(session.lane_clips(Lane::A1).len(), 2);
118 assert!(session.lane_clips(Lane::V1).is_empty(), "still no picture");116 assert!(session.lane_clips(Lane::V1).is_empty(), "still no picture");
119 117
@@ -345,13 +343,11 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() {
345 );343 );
346 // ...and the same reading with a clip under it is the clip menu, untouched:344 // ...and the same reading with a clip under it is the clip menu, untouched:
347 // the flag is off wherever a `Clip` was clicked.345 // the flag is off wherever a `Clip` was clicked.
348- assert!(346+ assert!(menu_items(Ctx {
349- menu_items(Ctx {
350 timeline: true,347 timeline: true,
351 ..Ctx::default()348 ..Ctx::default()
352 })349 })
353- .contains(&ActionId::Cut)350+ .contains(&ActionId::Cut));
354- );
355 }351 }
356 352
357 /// A timeline with a subtitle palette and an empty subtitle lane: what a353 /// A timeline with a subtitle palette and an empty subtitle lane: what a
@@ -617,6 +613,20 @@ fn the_playhead_actions_still_work_with_a_caption_marked() {
617 let clips = session.lane_clips(Lane::V1).len();613 let clips = session.lane_clips(Lane::V1).len();
618 assert!(session.cut_at(2.0), "the playhead splits the clip under it");614 assert!(session.cut_at(2.0), "the playhead splits the clip under it");
619 assert_eq!(session.lane_clips(Lane::V1).len(), clips + 1);615 assert_eq!(session.lane_clips(Lane::V1).len(), clips + 1);
616+ // The refusal is a real state and not a defence against nothing: the
617+ // playhead is standing on the seam the split just left, which is exactly the
618+ // stroke `Player::cut` words as "NOTHING TO SPLIT — the playhead is already
619+ // on a cut".
620+ assert!(
621+ !session.cut_at(2.0),
622+ "a second split on the seam is refused, which is the state the door's \
623+ selection gate is about"
624+ );
625+ assert_eq!(
626+ session.lane_clips(Lane::V1).len(),
627+ clips + 1,
628+ "and adds none"
629+ );
620 assert!(session.regroup_at(2.0), "and the seam rejoins");630 assert!(session.regroup_at(2.0), "and the seam rejoins");
621 assert_eq!(session.lane_clips(Lane::V1).len(), clips);631 assert_eq!(session.lane_clips(Lane::V1).len(), clips);
622 assert_eq!(session.sub_lane(lane).len(), 1, "the caption is untouched");632 assert_eq!(session.sub_lane(lane).len(), 1, "the caption is untouched");
@@ -939,16 +949,14 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() {
939 }949 }
940 assert!(!whole(ActionId::Delete, live).yes());950 assert!(!whole(ActionId::Delete, live).yes());
941 assert!(!whole(ActionId::Paste, live).yes());951 assert!(!whole(ActionId::Paste, live).yes());
942- assert!(952+ assert!(whole(
943- whole(
944 ActionId::Paste,953 ActionId::Paste,
945 Ctx {954 Ctx {
946 clipboard: true,955 clipboard: true,
947 ..live956 ..live
948 }957 }
949 )958 )
950- .yes()959+ .yes());
951- );
952 assert!(!whole(ActionId::CancelExport, live).yes());960 assert!(!whole(ActionId::CancelExport, live).yes());
953 let busy = Ctx {961 let busy = Ctx {
954 exporting: true,962 exporting: true,
@@ -988,7 +996,10 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() {
988 assert_eq!(menu_at(point(px(10.), px(10.)), viewport, 150.), (10., 10.));996 assert_eq!(menu_at(point(px(10.), px(10.)), viewport, 150.), (10., 10.));
989 assert_eq!(997 assert_eq!(
990 menu_at(point(px(700.), px(380.)), viewport, 150.),998 menu_at(point(px(700.), px(380.)), viewport, 150.),
991- (800. - crate::layout::MENU_EDGE - MENU_W, 400. - crate::layout::MENU_EDGE - 150.)999+ (
1000+ 800. - crate::layout::MENU_EDGE - MENU_W,
1001+ 400. - crate::layout::MENU_EDGE - 150.
1002+ )
992 );1003 );
993 // A window smaller than the menu loses its bottom, never its top: the1004 // A window smaller than the menu loses its bottom, never its top: the
994 // top-left margin wins over the bottom-right one, because the items are1005 // top-left margin wins over the bottom-right one, because the items are
@@ -1165,16 +1176,14 @@ fn a_menu_offers_only_what_applies_and_is_drawn_inside_the_window() {
1165 assert!(row_enable(RowItem::RemoveWithClips, placed).yes());1176 assert!(row_enable(RowItem::RemoveWithClips, placed).yes());
1166 let unplaced = row_items(live);1177 let unplaced = row_items(live);
1167 assert!(unplaced.contains(&RowItem::Remove) && !unplaced.contains(&RowItem::RemoveWithClips));1178 assert!(unplaced.contains(&RowItem::Remove) && !unplaced.contains(&RowItem::RemoveWithClips));
1168- assert!(1179+ assert!(!row_enable(
1169- !row_enable(
1170 RowItem::RemoveWithClips,1180 RowItem::RemoveWithClips,
1171 RowCtx {1181 RowCtx {
1172 exporting: true,1182 exporting: true,
1173 ..placed1183 ..placed
1174 }1184 }
1175 )1185 )
1176- .yes()1186+ .yes());
1177- );
1178 assert!(!row_enable(RowItem::Add, RowCtx::default()).yes());1187 assert!(!row_enable(RowItem::Add, RowCtx::default()).yes());
1179 // Every refusal is short enough to sit in the hint column beside its1188 // Every refusal is short enough to sit in the hint column beside its
1180 // label, the clip menu's rule.1189 // label, the clip menu's rule.
@@ -1282,7 +1291,11 @@ fn the_hanging_menus_mount_at_the_room_root_and_their_rows_wear_chords_not_prose
1282 }1291 }
1283 // §9: no junk drawer. A label that fits the plate whole beside its1292 // §9: no junk drawer. A label that fits the plate whole beside its
1284 // chord, and never a sentence.1293 // chord, and never a sentence.
1285- assert!(item.label().split_whitespace().count() <= 4, "{}", item.label());1294+ assert!(
1295+ item.label().split_whitespace().count() <= 4,
1296+ "{}",
1297+ item.label()
1298+ );
1286 }1299 }
1287 // The two removes must not read as the same verb now that the column1300 // The two removes must not read as the same verb now that the column
1288 // beside them is empty.1301 // beside them is empty.
@@ -1604,11 +1617,9 @@ fn adding_a_row_drops_the_whole_source_in_at_the_playhead() {
1604 let frames = session.file_frames(&second);1617 let frames = session.file_frames(&second);
1605 // Through the engine door `insert_source` uses, with the row's own1618 // Through the engine door `insert_source` uses, with the row's own
1606 // stream: the button, the drop and this are one call.1619 // stream: the button, the drop and this are one call.
1607- assert!(1620+ assert!(session
1608- session
1609 .place_stream_at(2.0, &second, 0, None)1621 .place_stream_at(2.0, &second, 0, None)
1610- .expect("av2 is already on the timeline")1622+ .expect("av2 is already on the timeline"));
1611- );
1612 // The whole of source 1 went in and nothing was painted over: the1623 // The whole of source 1 went in and nothing was painted over: the
1613 // timeline is longer by exactly that file.1624 // timeline is longer by exactly that file.
1614 assert_eq!(session.timeline_duration(), 9.0);1625 assert_eq!(session.timeline_duration(), 9.0);
@@ -1635,11 +1646,9 @@ fn adding_a_row_drops_the_whole_source_in_at_the_playhead() {
1635 let path = session.sources()[0].path.clone();1646 let path = session.sources()[0].path.clone();
1636 let frames = session.file_frames(&path);1647 let frames = session.file_frames(&path);
1637 let end = session.timeline_duration();1648 let end = session.timeline_duration();
1638- assert!(1649+ assert!(session
1639- session
1640 .place_stream_at(end, &path, 1, None)1650 .place_stream_at(end, &path, 1, None)
1641- .expect("the French track shares the timeline's parameters")1651+ .expect("the French track shares the timeline's parameters"));
1642- );
1643 assert_eq!(session.sources()[1].audio_stream, 1);1652 assert_eq!(session.sources()[1].audio_stream, 1);
1644 assert_eq!(session.timeline_duration(), end * 2.0);1653 assert_eq!(session.timeline_duration(), end * 2.0);
1645 // Both rows are the same file, so both rows are that file's length --1654 // Both rows are the same file, so both rows are that file's length --
@@ -1689,11 +1698,9 @@ fn a_row_dropped_on_the_open_bed_lands_under_the_pointer() {
1689 1698
1690 // ...and what the release does with it: the frame back through the same1699 // ...and what the release does with it: the frame back through the same
1691 // rate every box is drawn at, into the door the Add button uses too.1700 // rate every box is drawn at, into the door the Add button uses too.
1692- assert!(1701+ assert!(session
1693- session
1694 .place_stream_at(f64::from(at) / fps, &second, 0, None)1702 .place_stream_at(f64::from(at) / fps, &second, 0, None)
1695- .expect("av2 is already on this timeline")1703+ .expect("av2 is already on this timeline"));
1696- );
1697 let head = |lane| {1704 let head = |lane| {
1698 session1705 session
1699 .lane_clips(lane)1706 .lane_clips(lane)
@@ -1727,11 +1734,9 @@ fn removing_a_row_is_refused_while_it_plays_and_takes_the_row_away() {
1727 session.import(&asset("test_av2.mp4")).expect("av2 matches");1734 session.import(&asset("test_av2.mp4")).expect("av2 matches");
1728 let second = session.sources()[1].path.clone();1735 let second = session.sources()[1].path.clone();
1729 let end = session.timeline_duration();1736 let end = session.timeline_duration();
1730- assert!(1737+ assert!(session
1731- session
1732 .place_stream_at(end, &second, 0, None)1738 .place_stream_at(end, &second, 0, None)
1733- .expect("a file just imported is on this timeline")1739+ .expect("a file just imported is on this timeline"));
1734- );
1735 let streams = HashMap::new();1740 let streams = HashMap::new();
1736 let rows = |session: &PlaybackSession| {1741 let rows = |session: &PlaybackSession| {
1737 library_rows(session.sources(), &streams, &HashMap::new(), None, |_| 0).len()1742 library_rows(session.sources(), &streams, &HashMap::new(), None, |_| 0).len()
@@ -2058,11 +2063,9 @@ fn a_track_can_be_added_dropped_on_edited_and_taken_back() {
2058 // A library row let go over that row: the same door the Add button2063 // A library row let go over that row: the same door the Add button
2059 // uses, told which lane it was let go over.2064 // uses, told which lane it was let go over.
2060 let path = session.sources()[0].path.clone();2065 let path = session.sources()[0].path.clone();
2061- assert!(2066+ assert!(session
2062- session
2063 .place_stream_at(1.0, &path, 0, Some(v2))2067 .place_stream_at(1.0, &path, 0, Some(v2))
2064- .expect("its own file is on this timeline")2068+ .expect("its own file is on this timeline"));
2065- );
2066 assert_eq!(session.lane_clips(v2).len(), 1, "the drop landed on V2");2069 assert_eq!(session.lane_clips(v2).len(), 1, "the drop landed on V2");
2067 assert_eq!(session.lane_clips(v2)[0].start, 30, "at the playhead");2070 assert_eq!(session.lane_clips(v2)[0].start, 30, "at the playhead");
2068 // ...with the sound it came with, on the row of its own the drop added:2071 // ...with the sound it came with, on the row of its own the drop added:
@@ -2149,22 +2152,18 @@ fn a_selection_drag_moves_every_pick_by_the_same_delta() {
2149 2152
2150 // clip0 on V1 at the fixture's own start; clip1 on V1 ten seconds in,2153 // clip0 on V1 at the fixture's own start; clip1 on V1 ten seconds in,
2151 // appended to the open bed and rippling nothing.2154 // appended to the open bed and rippling nothing.
2152- assert!(2155+ assert!(session
2153- session
2154 .place_stream_at(10.0, &second, 0, None)2156 .place_stream_at(10.0, &second, 0, None)
2155- .expect("av2 is on this timeline")2157+ .expect("av2 is on this timeline"));
2156- );
2157 let clip0 = session.lane_clips(Lane::V1)[0];2158 let clip0 = session.lane_clips(Lane::V1)[0];
2158 let clip1 = session.lane_clips(Lane::V1)[1];2159 let clip1 = session.lane_clips(Lane::V1)[1];
2159 assert_eq!((clip0.start, clip1.start), (0, 300));2160 assert_eq!((clip0.start, clip1.start), (0, 300));
2160 2161
2161 // clipC on a second video row, well past both of the above.2162 // clipC on a second video row, well past both of the above.
2162 let v2 = session.add_lane(LaneKind::Video);2163 let v2 = session.add_lane(LaneKind::Video);
2163- assert!(2164+ assert!(session
2164- session
2165 .place_stream_at(20.0, &path, 0, Some(v2))2165 .place_stream_at(20.0, &path, 0, Some(v2))
2166- .expect("test_av.mp4 is on this timeline")2166+ .expect("test_av.mp4 is on this timeline"));
2167- );
2168 let clip_c = session.lane_clips(v2)[0];2167 let clip_c = session.lane_clips(v2)[0];
2169 assert_eq!(clip_c.start, 600);2168 assert_eq!(clip_c.start, 600);
2170 2169
@@ -2217,28 +2216,22 @@ fn a_selection_drag_refuses_as_one_set_when_any_pick_cannot_land() {
2217 session.import(&asset("test_av2.mp4")).expect("av2 matches");2216 session.import(&asset("test_av2.mp4")).expect("av2 matches");
2218 let second = session.sources()[1].path.clone();2217 let second = session.sources()[1].path.clone();
2219 2218
2220- assert!(2219+ assert!(session
2221- session
2222 .place_stream_at(10.0, &second, 0, None)2220 .place_stream_at(10.0, &second, 0, None)
2223- .expect("av2 is on this timeline")2221+ .expect("av2 is on this timeline"));
2224- );
2225 let clip0 = session.lane_clips(Lane::V1)[0];2222 let clip0 = session.lane_clips(Lane::V1)[0];
2226 let clip1 = session.lane_clips(Lane::V1)[1];2223 let clip1 = session.lane_clips(Lane::V1)[1];
2227 2224
2228 let v2 = session.add_lane(LaneKind::Video);2225 let v2 = session.add_lane(LaneKind::Video);
2229- assert!(2226+ assert!(session
2230- session
2231 .place_stream_at(0.0, &path, 0, Some(v2))2227 .place_stream_at(0.0, &path, 0, Some(v2))
2232- .expect("test_av.mp4 is on this timeline")2228+ .expect("test_av.mp4 is on this timeline"));
2233- );
2234 let clip_c = session.lane_clips(v2)[0];2229 let clip_c = session.lane_clips(v2)[0];
2235 // A clip clip1 is not picked, blocking the road on V2 the drag is about2230 // A clip clip1 is not picked, blocking the road on V2 the drag is about
2236 // to try: clip1 dragged onto V2 lands its head inside this one.2231 // to try: clip1 dragged onto V2 lands its head inside this one.
2237- assert!(2232+ assert!(session
2238- session
2239 .place_stream_at(10.0, &second, 0, Some(v2))2233 .place_stream_at(10.0, &second, 0, Some(v2))
2240- .expect("av2 is on this timeline")2234+ .expect("av2 is on this timeline"));
2241- );
2242 let blocker = session.lane_clips(v2)[1];2235 let blocker = session.lane_clips(v2)[1];
2243 assert_eq!(blocker.start, 300);2236 assert_eq!(blocker.start, 300);
2244 2237
@@ -2293,20 +2286,16 @@ fn a_three_pick_copy_paste_preserves_gaps_and_lane_assignment() {
2293 session.import(&asset("test_av2.mp4")).expect("av2 matches");2286 session.import(&asset("test_av2.mp4")).expect("av2 matches");
2294 let second = session.sources()[1].path.clone();2287 let second = session.sources()[1].path.clone();
2295 2288
2296- assert!(2289+ assert!(session
2297- session
2298 .place_stream_at(10.0, &second, 0, None)2290 .place_stream_at(10.0, &second, 0, None)
2299- .expect("av2 is on this timeline")2291+ .expect("av2 is on this timeline"));
2300- );
2301 let clip0 = session.lane_clips(Lane::V1)[0];2292 let clip0 = session.lane_clips(Lane::V1)[0];
2302 let clip1 = session.lane_clips(Lane::V1)[1];2293 let clip1 = session.lane_clips(Lane::V1)[1];
2303 2294
2304 let v2 = session.add_lane(LaneKind::Video);2295 let v2 = session.add_lane(LaneKind::Video);
2305- assert!(2296+ assert!(session
2306- session
2307 .place_stream_at(20.0, &path, 0, Some(v2))2297 .place_stream_at(20.0, &path, 0, Some(v2))
2308- .expect("test_av.mp4 is on this timeline")2298+ .expect("test_av.mp4 is on this timeline"));
2309- );
2310 let clip_c = session.lane_clips(v2)[0];2299 let clip_c = session.lane_clips(v2)[0];
2311 2300
2312 // Copied in click order, out of the lanes each was clicked in -- exactly2301 // Copied in click order, out of the lanes each was clicked in -- exactly
@@ -2354,20 +2343,16 @@ fn a_colliding_set_paste_refuses_whole() {
2354 session.import(&asset("test_av2.mp4")).expect("av2 matches");2343 session.import(&asset("test_av2.mp4")).expect("av2 matches");
2355 let second = session.sources()[1].path.clone();2344 let second = session.sources()[1].path.clone();
2356 2345
2357- assert!(2346+ assert!(session
2358- session
2359 .place_stream_at(10.0, &second, 0, None)2347 .place_stream_at(10.0, &second, 0, None)
2360- .expect("av2 is on this timeline")2348+ .expect("av2 is on this timeline"));
2361- );
2362 let clip0 = session.lane_clips(Lane::V1)[0];2349 let clip0 = session.lane_clips(Lane::V1)[0];
2363 let clip1 = session.lane_clips(Lane::V1)[1];2350 let clip1 = session.lane_clips(Lane::V1)[1];
2364 2351
2365 let v2 = session.add_lane(LaneKind::Video);2352 let v2 = session.add_lane(LaneKind::Video);
2366- assert!(2353+ assert!(session
2367- session
2368 .place_stream_at(20.0, &path, 0, Some(v2))2354 .place_stream_at(20.0, &path, 0, Some(v2))
2369- .expect("test_av.mp4 is on this timeline")2355+ .expect("test_av.mp4 is on this timeline"));
2370- );
2371 let clip_c = session.lane_clips(v2)[0];2356 let clip_c = session.lane_clips(v2)[0];
2372 2357
2373 let items = [(Lane::V1, clip0), (Lane::V1, clip1), (v2, clip_c)];2358 let items = [(Lane::V1, clip0), (Lane::V1, clip1), (v2, clip_c)];
@@ -2422,11 +2407,9 @@ fn a_grouped_clip_on_an_added_lane_closes_its_hole_with_its_caption() {
2422 let (mut session, sub_lane) = with_subtitle_lane();2407 let (mut session, sub_lane) = with_subtitle_lane();
2423 let v2 = session.add_lane(LaneKind::Video);2408 let v2 = session.add_lane(LaneKind::Video);
2424 let path = session.sources()[0].path.clone();2409 let path = session.sources()[0].path.clone();
2425- assert!(2410+ assert!(session
2426- session
2427 .place_stream_at(0.0, &path, 0, Some(v2))2411 .place_stream_at(0.0, &path, 0, Some(v2))
2428- .expect("its own file is on this timeline")2412+ .expect("its own file is on this timeline"));
2429- );
2430 session2413 session
2431 .place_sub(sub_lane, 0, one_second(0))2414 .place_sub(sub_lane, 0, one_second(0))
2432 .expect("the caption goes down");2415 .expect("the caption goes down");
@@ -2722,6 +2705,35 @@ fn escape_closes_a_card_before_it_can_ever_reach_deselect() {
2722 }2705 }
2723 }2706 }
2724 2707
2708+/// A refused split is not an edit, so it may not drop the clip in hand: the
2709+/// refused stroke is worded ("NOTHING TO SPLIT — the playhead is already on a
2710+/// cut") and the pick is still what the next `x`, `delete` or clip-menu row acts
2711+/// on. The clear rides the door's own answer, the way [`Player::regroup`]'s
2712+/// always has -- a split that happened is the other way round: the seam it
2713+/// leaves renumbers the lane, so a pick kept across it names the wrong clip.
2714+///
2715+/// A scan and not a drive: `self.selected` lives on `Player`, which needs a gpui
2716+/// `Context` this binary has no harness for. The state itself is driven in
2717+/// `the_playhead_actions_still_work_with_a_caption_marked`, which holds the real
2718+/// `cut_at` refusal this gate is about.
2719+#[test]
2720+fn a_refused_split_keeps_the_clip_in_hand() {
2721+ let body = fn_body("cut");
2722+ let (before, after) = body
2723+ .split_once("if cut {")
2724+ .expect("the split door no longer gates anything on its own answer");
2725+ assert!(
2726+ !before.contains("self.selected.clear()"),
2727+ "the split drops the selection before it knows the cut happened, so a \
2728+ refused split leaves the user with nothing picked and nothing told"
2729+ );
2730+ assert!(
2731+ after.contains("self.selected.clear()"),
2732+ "a split that happened no longer drops the selection, so the mark names \
2733+ a different clip on the far side of the seam"
2734+ );
2735+}
2736+
2725 /// The other half: with nothing on screen to claim the key, bare escape falls2737 /// The other half: with nothing on screen to claim the key, bare escape falls
2726 /// all the way through to `Player::act`, whose `ActionId::Deselect` arm is2738 /// all the way through to `Player::act`, whose `ActionId::Deselect` arm is
2727 /// the one place `self.selected` is emptied by a bare stroke rather than by2739 /// the one place `self.selected` is emptied by a bare stroke rather than by
@@ -2802,13 +2814,21 @@ fn every_verb_the_spine_carried_is_a_right_click_row() {
2802 // Every menu is a list of actions the keyboard already reaches, so every2814 // Every menu is a list of actions the keyboard already reaches, so every
2803 // row can wear its chord (DESIGN §4): a row built here out of an id the2815 // row can wear its chord (DESIGN §4): a row built here out of an id the
2804 // registry never files would print an empty column.2816 // registry never files would print an empty column.
2805- for action in MENU_ITEMS.into_iter().chain(BENCH_ITEMS).chain(heads.iter().copied()) {2817+ for action in MENU_ITEMS
2818+ .into_iter()
2819+ .chain(BENCH_ITEMS)
2820+ .chain(heads.iter().copied())
2821+ {
2806 assert!(2822 assert!(
2807 ActionId::ALL.contains(&action),2823 ActionId::ALL.contains(&action),
2808 "{action:?} is a menu row and not a registered action"2824 "{action:?} is a menu row and not a registered action"
2809 );2825 );
2810 }2826 }
2811- for list in [MENU_ITEMS.to_vec(), BENCH_ITEMS.to_vec(), lane_items(Lane::A1)] {2827+ for list in [
2828+ MENU_ITEMS.to_vec(),
2829+ BENCH_ITEMS.to_vec(),
2830+ lane_items(Lane::A1),
2831+ ] {
2812 let first = list.iter().position(|&a| destructive(a));2832 let first = list.iter().position(|&a| destructive(a));
2813 if let Some(first) = first {2833 if let Some(first) = first {
2814 assert!(2834 assert!(