Dock: dragging a divider past a panel's minimum no longer crashes the app (#306)
A split's first side was sized with `f32::clamp(20.min(avail), (avail - 20).max(0))`. `f32::clamp` panics when its lower bound exceeds its upper one, which happened for any split with 0 < avail < 40 pt. Dragging the viewer/Timeline divider up takes the area above it down to 40 pt, so the splits nested there (the right column's vertical split and others) got about 36 pt and the layout panicked; no guard covers egui's update, so the app closed with no dialog. The split size now goes through `split_first` / `clamp_ordered`, which never panic: when the room is too small for both minimums the lower bound wins, and non-finite sizes fall back to it. The gutter drag uses the same clamp. Tests: a dock unit test lays out every workspace in rects too short and too narrow for its minimums (it panicked before) and checks `split_first` on hostile sizes; a kittest drags the divider above the Timeline 2000 pt up and 3000 pt down. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
This commit is contained in:
@@ -298,3 +298,30 @@ fn project_empty_area_double_click_and_dropped_files_import() {
|
||||
h.run_steps(2);
|
||||
assert_eq!(imports(&h), 2, "the dropped file was imported");
|
||||
}
|
||||
|
||||
/// Issue #306: dragging the viewer/Timeline divider far up made a nested split shorter than its
|
||||
/// two 20 pt minimums, and `f32::clamp` panicked with crossed bounds, closing the app.
|
||||
#[test]
|
||||
fn dragging_the_viewer_timeline_divider_far_up_does_not_crash() {
|
||||
let (mut h, _, _) = harness();
|
||||
// The horizontal gutter right above the Timeline.
|
||||
let tl = rect(&h, "panel.Timeline");
|
||||
let gutter = |h: &Harness<'_, EffectcraftApp>| {
|
||||
h.state()
|
||||
.auto
|
||||
.previous
|
||||
.iter()
|
||||
.filter(|e| e.id.starts_with("dock.gutter.") && e.rect[2] > e.rect[3])
|
||||
.map(|e| (e.id.clone(), egui::Rect::from_min_size(pos2(e.rect[0], e.rect[1]), egui::vec2(e.rect[2], e.rect[3]))))
|
||||
.filter(|(_, g)| g.x_range().contains(tl.center().x) && g.max.y <= tl.min.y + 1.0)
|
||||
.min_by(|a, b| (tl.min.y - a.1.max.y).total_cmp(&(tl.min.y - b.1.max.y)))
|
||||
.expect("the gutter above the Timeline")
|
||||
};
|
||||
let (id, g) = gutter(&h);
|
||||
drag(&mut h, g.center(), g.center() - egui::vec2(0.0, 2000.0));
|
||||
let g2 = rect(&h, &id);
|
||||
assert!(g2.center().y < g.center().y - 100.0, "the divider moved up: {g:?} → {g2:?}");
|
||||
// And back down past the bottom.
|
||||
drag(&mut h, g2.center(), g2.center() + egui::vec2(0.0, 3000.0));
|
||||
h.run_steps(2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user