Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

#208: Go to In / Go to Out move to the sequence start / end without marks

carlitosteso37392a69d0f7d
diff --git a/crates/engine/src/commands.rs b/crates/engine/src/commands.rs
index acdccda75..8db2baad1 100644
--- a/crates/engine/src/commands.rs
+++ b/crates/engine/src/commands.rs
@@ -1609,14 +1609,15 @@ fn build() -> Vec<CommandSpec> {
})?;
Ok(Value::Null)
}),
+ // With no In / Out mark, like Premiere: the start / end of the sequence (#208).
cmd!("markers.goToIn", "Go to In", ["Markers"], Some("Shift+I"), "{}", has_seq, |s, _| {
- if let Some(i) = s.active_sequence().and_then(|q| q.mark_in) {
+ if let Some(i) = s.active_sequence().map(|q| q.mark_in.unwrap_or(Tick::ZERO)) {
s.set_playhead(i);
}
Ok(Value::Null)
}),
cmd!("markers.goToOut", "Go to Out", ["Markers"], Some("Shift+O"), "{}", has_seq, |s, _| {
- if let Some(o) = s.active_sequence().and_then(|q| q.mark_out) {
+ if let Some(o) = s.active_sequence().map(|q| q.mark_out.unwrap_or_else(|| q.duration())) {
s.set_playhead(o);
}
Ok(Value::Null)
diff --git a/crates/engine/src/sequence_tools_tests.rs b/crates/engine/src/sequence_tools_tests.rs
index d9df881f4..aa81758ca 100644
--- a/crates/engine/src/sequence_tools_tests.rs
+++ b/crates/engine/src/sequence_tools_tests.rs
@@ -483,3 +483,24 @@ fn selection_follows_playhead() {
s.execute("playhead.set", json!({"frame": 10})).unwrap();
assert_eq!(s.state.selection, sel, "off again");
}
+
+/// #208: with no In / Out mark, Go to In / Go to Out move to the start / end of the sequence
+/// (they did nothing); with marks they go to them.
+#[test]
+fn go_to_in_out_without_marks_go_to_the_sequence_ends() {
+ let mut s = demo();
+ let end = s.active_sequence().unwrap().duration();
+ let mid = filmcraft_time::Tick(end.0 / 2);
+ s.execute("playhead.set", json!({"time": mid.0})).unwrap();
+ s.execute("markers.goToIn", json!({})).unwrap();
+ assert_eq!(s.playhead(), filmcraft_time::Tick::ZERO, "the start");
+ s.execute("markers.goToOut", json!({})).unwrap();
+ assert_eq!(s.playhead(), end, "the end");
+ // with marks, the marks
+ let at = filmcraft_time::Tick(end.0 / 4);
+ s.execute("playhead.set", json!({"time": at.0})).unwrap();
+ s.execute("markers.markIn", json!({})).unwrap();
+ s.execute("playhead.set", json!({"time": mid.0})).unwrap();
+ s.execute("markers.goToIn", json!({})).unwrap();
+ assert_eq!(s.playhead(), s.active_sequence().unwrap().mark_in.unwrap());
+}