Skip to content

fix: use i32 for use_component_rect to prevent overflow#176

Merged
ccbrown merged 1 commit intoccbrown:mainfrom
domenkozar:fix-use-component-rect-overflow
Mar 2, 2026
Merged

fix: use i32 for use_component_rect to prevent overflow#176
ccbrown merged 1 commit intoccbrown:mainfrom
domenkozar:fix-use-component-rect-overflow

Conversation

@domenkozar
Copy link
Contributor

Summary

  • canvas_position() returns Point<i16> and size() returns Size<u16>. Combining them in a Rect<u16> caused arithmetic overflow for off-screen components inside a ScrollView.
  • Changed use_component_rect to use i32 to prevent the overflow.

Test plan

  • Verified that components inside a ScrollView that are off-screen no longer cause arithmetic overflow panics.

🤖 Generated with Claude Code

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.06%. Comparing base (766e650) to head (99ed0b9).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #176   +/-   ##
=======================================
  Coverage   89.06%   89.06%           
=======================================
  Files          34       34           
  Lines        5826     5826           
  Branches     5826     5826           
=======================================
  Hits         5189     5189           
  Misses        526      526           
  Partials      111      111           
Files with missing lines Coverage Δ
packages/iocraft/src/hooks/use_component_rect.rs 97.56% <100.00%> (ø)

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

canvas_position() returns Point<i16> and size() returns Size<u16>.
Combining them in a Rect<u16> caused arithmetic overflow for
off-screen components inside a ScrollView.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@domenkozar domenkozar force-pushed the fix-use-component-rect-overflow branch from cfb158a to 99ed0b9 Compare March 2, 2026 00:21
Copy link
Owner

@ccbrown ccbrown left a comment

Choose a reason for hiding this comment

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

Looks fine to me, especially since this is still unreleased.

I've been considering a breaking change to replace all of the 16 bit types with 32 bit types anyway since there may be reasonable cases where coordinates beyond 65,535 are possible.

@ccbrown ccbrown merged commit f475e51 into ccbrown:main Mar 2, 2026
5 checks passed
@domenkozar
Copy link
Contributor Author

Yeah I was looking at making size() return i16 and gave up as it may be too much breakage :) I do appreciate a clean api so 👍 from me

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.

2 participants