FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
Enable only the Alt-selected side of a linked clip (#3235)
NetterSilver149827d1a4b2
diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rsindex 8f54af3e9..1089046fc 100644--- a/crates/engine/src/commands.rs+++ b/crates/engine/src/commands.rs@@ -1915,7 +1915,8 @@ fn build() -> Vec<CommandSpec> {// Each clip flips on its own, as in Premiere (#484): with one enabled and one disabled clip// selected, Enable swaps them rather than first making both the same.cmd!("clip.enable", "Enable", ["Clip"], Some("Shift+E"), r#"{"clips":[id]?}"#, has_selection, |s, p| {- let mut sel = with_links(s, &clips_p(s, p));+ // An Alt selection is already exact (#3031); explicit targets keep the linked behavior.+ let mut sel = if p.get("clips").is_some() || p.get("clip").is_some() { with_links(s, &clips_p(s, p)) } else { s.state.selection.clone() };// a clip named twice must still flip oncesel.sort();sel.dedup();diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rsindex 1161a2c3b..8034a4020 100644--- a/crates/engine/src/tests.rs+++ b/crates/engine/src/tests.rs@@ -1119,6 +1119,31 @@ fn enable_flips_each_selected_clip() {assert_eq!((enabled(&s, a), enabled(&s, b)), (true, true));}+/// #3031: with linked selection on, Enable on an Alt-selected audio clip flips only that clip,+/// while a linked selection still flips both sides.+#[test]+fn enable_on_an_individual_selection_leaves_the_linked_partner() {+ let mut s = demo();+ assert!(s.state.linked_selection);+ let enabled = |s: &Session, c: ClipId| s.active_sequence().unwrap().find_item(c).unwrap().1.enabled;+ let video = ClipId(v1(&s)[0].0);+ let audio = {+ let q = s.active_sequence().unwrap();+ let link = q.find_item(video).unwrap().1.link.unwrap();+ q.all_tracks().flat_map(|t| t.items.iter()).find(|i| i.link == Some(link) && i.id != video).unwrap().id+ };+ s.execute("timeline.select", json!({"clips": [audio.0], "linked": false})).unwrap();+ assert_eq!(s.state.selection, vec![audio]);+ s.execute("clip.enable", json!({})).unwrap();+ assert_eq!((enabled(&s, video), enabled(&s, audio)), (true, false), "only the selected audio is disabled");+ s.execute("clip.enable", json!({})).unwrap();+ assert_eq!((enabled(&s, video), enabled(&s, audio)), (true, true));+ // a linked selection still flips both sides+ s.execute("timeline.select", json!({"clips": [audio.0], "linked": true})).unwrap();+ s.execute("clip.enable", json!({})).unwrap();+ assert_eq!((enabled(&s, video), enabled(&s, audio)), (false, false));+}+/// #580: Escape takes back what a gesture changed, merged or not: the project returns to the mark,/// neither undo nor redo keeps the changes, and older steps stay.#[test]