[PR #13256] Fix signed/unsigned arithmetic bug during scrolling #29442

Open
opened 2026-01-31 09:34:56 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/13256

State: closed
Merged: Yes


ed27737 contains a regression where (pseudocode)

unsigned long ulActualDelta;
short ScreenInfo.WheelDelta;
delta *= (ScreenInfo.WheelDelta / (short)ulActualDelta);
//                                ^^^^^^^

was changed to

delta *= (ScreenInfo.WheelDelta / ulActualDelta);

Due to ulActualDelta being unsigned, the new code casts the signed integer
to a unsigned one first, before doing the division. This causes scrolling
downwards (WheelDelta is negative) to appear as a large positive delta.

PR Checklist

Validation Steps Performed

  • Scrolling up/down works in OpenConsole again
**Original Pull Request:** https://github.com/microsoft/terminal/pull/13256 **State:** closed **Merged:** Yes --- ed27737 contains a regression where (pseudocode) ```c unsigned long ulActualDelta; short ScreenInfo.WheelDelta; delta *= (ScreenInfo.WheelDelta / (short)ulActualDelta); // ^^^^^^^ ``` was changed to ```c delta *= (ScreenInfo.WheelDelta / ulActualDelta); ``` Due to `ulActualDelta` being unsigned, the new code casts the signed integer to a unsigned one first, before doing the division. This causes scrolling downwards (`WheelDelta` is negative) to appear as a large positive `delta`. ## PR Checklist * [x] Closes #13253 * [x] I work here ## Validation Steps Performed * Scrolling up/down works in OpenConsole again ✅
claunia added the pull-request label 2026-01-31 09:34:56 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#29442