From 19469c713967e8ae2c4869fa33e87756eb5ba358 Mon Sep 17 00:00:00 2001 From: Aditya Garud <153842990+yashranaway@users.noreply.github.com> Date: Wed, 21 Oct 2026 13:20:51 +0000 Subject: [PATCH 1/2] fix(desktop-gpui): stop zoom resizes overlapping adjacent segments --- apps/desktop-gpui/src/editor_edits.rs | 59 ++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/apps/desktop-gpui/src/editor_edits.rs b/apps/desktop-gpui/src/editor_edits.rs index f2df27fdd60..165c9220f6a 100644 --- a/apps/desktop-gpui/src/editor_edits.rs +++ b/apps/desktop-gpui/src/editor_edits.rs @@ -437,7 +437,6 @@ pub fn trim_start_bounds( } /// `SegmentHandle position="end"`'s setup (`TL/MaskTrack.tsx:499-508`): -/// `minValue = start + minDuration`, `maxValue = max(minValue, nextStart)`. pub fn trim_end_bounds( segments: &[Segment], lane: u32, @@ -446,11 +445,9 @@ pub fn trim_end_bounds( total: f64, ) -> DragBounds { let (_, next_start) = neighbours(segments, lane, index, total); - let min = segments[index].start + min_duration; - DragBounds { - min, - max: min.max(next_start), - } + let max = next_start.max(segments[index].end); + let min = (segments[index].start + min_duration).min(max); + DragBounds { min, max } } pub fn audio_trim_start_bounds(segment: &AudioTrackSegment, bounds: DragBounds) -> DragBounds { @@ -3153,6 +3150,56 @@ mod tests { assert_eq!(bounds.clamp(4.), 0.); } + #[test] + fn zoom_end_resize_cannot_cross_a_neighbour_when_zoomed_out() { + let mut project = zoom_fixture(); + let timeline = project.timeline.as_mut().unwrap(); + timeline.zoom_segments[1].start = 6.; + let model = TimelineModel::build(&project, false, false); + let zoom = segments(&model, TrackKind::Zoom); + let floor = min_segment_duration(TrackKind::Zoom, 0.2); + let bounds = trim_end_bounds(&zoom, 0, 0, floor, 30.); + + assert_eq!(bounds, DragBounds { min: 6., max: 6. }); + let timeline = project.timeline.as_mut().unwrap(); + for requested_end in [4., 5.5, 12.] { + set_segment_end(timeline, TrackKind::Zoom, 0, bounds.clamp(requested_end)); + assert!(timeline.zoom_segments[0].end <= timeline.zoom_segments[1].start); + } + } + + #[test] + fn zoom_end_resize_cannot_cross_the_timeline_end_when_zoomed_out() { + let mut project = zoom_fixture(); + let model = TimelineModel::build(&project, false, false); + let zoom = segments(&model, TrackKind::Zoom); + let floor = min_segment_duration(TrackKind::Zoom, 0.5); + let bounds = trim_end_bounds(&zoom, 0, 1, floor, 30.); + + assert_eq!(bounds, DragBounds { min: 30., max: 30. }); + let timeline = project.timeline.as_mut().unwrap(); + for requested_end in [23., 28., 40.] { + set_segment_end(timeline, TrackKind::Zoom, 1, bounds.clamp(requested_end)); + assert!(timeline.zoom_segments[1].end <= timeline.duration()); + } + } + + #[test] + fn zoom_end_resize_preserves_a_range_left_beyond_a_shortened_timeline() { + let mut project = zoom_fixture(); + project.timeline.as_mut().unwrap().segments[0].end = 10.; + let model = TimelineModel::build(&project, false, false); + let zoom = segments(&model, TrackKind::Zoom); + let floor = min_segment_duration(TrackKind::Zoom, 0.2); + let bounds = trim_end_bounds(&zoom, 0, 1, floor, 10.); + + for requested_end in [8., 22., 30.] { + let end = bounds.clamp(requested_end); + assert!(end >= zoom[1].start); + assert!(end <= zoom[1].end); + } + } + // -- Clip trim ---------------------------------------------------------- fn two_clip_config() -> ProjectConfiguration { From fdc532513e8e7c259c56c187f9ab9e8f7e17851e Mon Sep 17 00:00:00 2001 From: Aditya Garud <153842990+yashranaway@users.noreply.github.com> Date: Wed, 21 Oct 2026 15:58:53 +0000 Subject: [PATCH 2/2] fix(desktop-gpui): keep a short segment from growing when its end is dragged left --- apps/desktop-gpui/src/editor_edits.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/desktop-gpui/src/editor_edits.rs b/apps/desktop-gpui/src/editor_edits.rs index 165c9220f6a..62ed9b8fba3 100644 --- a/apps/desktop-gpui/src/editor_edits.rs +++ b/apps/desktop-gpui/src/editor_edits.rs @@ -446,7 +446,9 @@ pub fn trim_end_bounds( ) -> DragBounds { let (_, next_start) = neighbours(segments, lane, index, total); let max = next_start.max(segments[index].end); - let min = (segments[index].start + min_duration).min(max); + let min = (segments[index].start + min_duration) + .min(segments[index].end) + .min(max); DragBounds { min, max } } @@ -3160,9 +3162,11 @@ mod tests { let floor = min_segment_duration(TrackKind::Zoom, 0.2); let bounds = trim_end_bounds(&zoom, 0, 0, floor, 30.); - assert_eq!(bounds, DragBounds { min: 6., max: 6. }); + assert_eq!(bounds, DragBounds { min: 5., max: 6. }); let timeline = project.timeline.as_mut().unwrap(); - for requested_end in [4., 5.5, 12.] { + set_segment_end(timeline, TrackKind::Zoom, 0, bounds.clamp(4.)); + assert_eq!(timeline.zoom_segments[0].end, 5.); + for requested_end in [5.5, 12.] { set_segment_end(timeline, TrackKind::Zoom, 0, bounds.clamp(requested_end)); assert!(timeline.zoom_segments[0].end <= timeline.zoom_segments[1].start); } @@ -3176,7 +3180,7 @@ mod tests { let floor = min_segment_duration(TrackKind::Zoom, 0.5); let bounds = trim_end_bounds(&zoom, 0, 1, floor, 30.); - assert_eq!(bounds, DragBounds { min: 30., max: 30. }); + assert_eq!(bounds, DragBounds { min: 24., max: 30. }); let timeline = project.timeline.as_mut().unwrap(); for requested_end in [23., 28., 40.] { set_segment_end(timeline, TrackKind::Zoom, 1, bounds.clamp(requested_end));