Skip to content

fix: avoid invalid transforms in repeat_array when count is 1#4237

Draft
Sanketjadhav31 wants to merge 1 commit into
GraphiteEditor:masterfrom
Sanketjadhav31:fix-repeat-array-nan-count-one
Draft

fix: avoid invalid transforms in repeat_array when count is 1#4237
Sanketjadhav31 wants to merge 1 commit into
GraphiteEditor:masterfrom
Sanketjadhav31:fix-repeat-array-nan-count-one

Conversation

@Sanketjadhav31

@Sanketjadhav31 Sanketjadhav31 commented Jun 15, 2026

Copy link
Copy Markdown

Summary

While looking through the repeat nodes, I noticed that repeat_array allows count = 1, but the calculation uses (count - 1) as a denominator.

When count is 1, this results in a zero denominator and can produce invalid transform values during the angle and translation calculations.

This change guards against that edge case by ensuring the denominator is at least 1.

Changes

  • Prevent division by zero when count = 1
  • Keep existing behavior unchanged for count >= 2

Testing

Reasoned through the count = 1 execution path and verified that the denominator can no longer become zero.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the repeat_array function in repeat_nodes.rs to ensure that the total calculation has a minimum value of 1.0 by using .max(1) on count - 1. This prevents potential division by zero or invalid calculations when count is 1. There are no review comments to evaluate.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant