Perspective Crop: a document of broken size snaps the drag start neither to a corner nor to an edge

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David MannandClaude Opus 5.5 committed 2026-11-29 15:23:46 +01:00
1 parent 9a0766e3d9
commit 779b536f71
1 file changed
+7 -4
+7 -4
View File
@@ -133,11 +133,14 @@ fn boxed(anchor: Point, to: Point) -> PerspectiveQuad {
/// Where a box drag pressed at `press` starts. While the canvas snaps to the document bounds
/// ([`ToolContext::snaps_to_document_bounds`]), a press beyond a document corner (outside on both axes) starts at that
/// corner, and one within the snap distance of an edge starts on the nearest edge ([`ToolContext::snap_of`]). Any other
/// press starts where it was. Clicked corners don't come here: they keep their place.
/// press, and every press on a document whose size is negative or not finite, starts where it was. Clicked corners
/// don't come here: they keep their place.
fn drag_start(press: Point, cx: &ToolContext<'_>) -> Point {
let document = cx.space().and_then(|space| space.document());
// A size that is negative or not finite has no corner to start at (and would make `clamp` panic).
let size = document.filter(|size| size.width.is_finite() && size.height.is_finite() && size.width >= 0.0 && size.height >= 0.0);
let size = cx.space().and_then(|space| space.document());
// A size that is negative or not finite has no bounds to start on (and would make `clamp` panic): no snap at all.
if size.is_some_and(|size| !(size.width.is_finite() && size.height.is_finite() && size.width >= 0.0 && size.height >= 0.0)) {
return press;
}
if let Some(size) = size
&& cx.snaps_to_document_bounds()
&& !(0.0..=size.width).contains(&press.x)