Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2175,14 +2175,14 @@ impl DocumentMessageHandler {
};

let size = existing_bottom_right - existing_top_left;
// TODO: This is a hacky band-aid. It still results in the shape becoming zero-sized. Properly fix this using the correct math.
// If size is zero we clamp it to minimun value to avoid dividing by zero vector to calculate enlargement.
let size = size.max(DVec2::ONE);
//Fixed by using correct Math for calculating the enlargement based on the resize direction and whether the opposite corner is being resized from
let enlargement = DVec2::new(
if resize_opposite_corner != opposite_x { -delta_x } else { delta_x },
if resize_opposite_corner != opposite_y { -delta_y } else { delta_y },
);
let enlargement_factor = (enlargement + size) / size;
let clamped_size = size.max(DVec2::ONE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Clamping the current size to 1 in the denominator makes resize scaling incorrect for sub-1px objects, causing tiny selections to resize very weakly.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At editor/src/messages/portfolio/document/document_message_handler.rs, line 2135:

<comment>Clamping the current size to 1 in the denominator makes resize scaling incorrect for sub-1px objects, causing tiny selections to resize very weakly.</comment>

<file context>
@@ -2127,14 +2127,14 @@ impl DocumentMessageHandler {
 			if resize_opposite_corner != opposite_y { -delta_y } else { delta_y },
 		);
-		let enlargement_factor = (enlargement + size) / size;
+		let clamped_size = size.max(DVec2::ONE);
+		let clamped_new_size = (size + enlargement).max(DVec2::ONE);
+		let enlargement_factor = clamped_new_size / clamped_size;
</file context>

let clamped_new_size = (size + enlargement).max(DVec2::ONE);
let enlargement_factor = clamped_new_size / clamped_size;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Clamped scale uses reduced resize delta, but position/pivot still use raw keyboard delta, causing incorrect translation when min-size clamp is hit.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At editor/src/messages/portfolio/document/document_message_handler.rs, line 2137:

<comment>Clamped scale uses reduced resize delta, but position/pivot still use raw keyboard delta, causing incorrect translation when min-size clamp is hit.</comment>

<file context>
@@ -2127,14 +2127,14 @@ impl DocumentMessageHandler {
-		let enlargement_factor = (enlargement + size) / size;
+		let clamped_size = size.max(DVec2::ONE);
+		let clamped_new_size = (size + enlargement).max(DVec2::ONE);
+		let enlargement_factor = clamped_new_size / clamped_size;
 
 		let position = DVec2::new(
</file context>


let position = DVec2::new(
existing_top_left.x + if resize_opposite_corner != opposite_x { delta_x } else { 0. },
Expand Down