Scroll wheel no longer works correctly in OpenConsole #17666

Closed
opened 2026-01-31 05:49:27 +00:00 by claunia · 2 comments
Owner

Originally created by @j4james on GitHub (Jun 9, 2022).

Originally assigned to: @lhecker on GitHub.

Windows Terminal version

Commit ed27737233

Windows build number

10.0.19044.1706

Other Software

No response

Steps to reproduce

  1. Checkout commit ed27737233 or later.
  2. Build and run OpenConsole.
  3. Perform a few directory listings or something to get a couple of pages into the buffer.
  4. Use the scroll wheel to scroll back in the buffer.
  5. Use the scroll wheel to scroll forward again.

Expected Behavior

Scrolling should work correctly in both directions.

Actual Behavior

When I attempt to scroll forward, the viewport immediately jumps back to the start of the buffer.

I did a git bisect, and it looks like this problem may have been introduced by commit ed27737233.

/cc @lhecker

Originally created by @j4james on GitHub (Jun 9, 2022). Originally assigned to: @lhecker on GitHub. ### Windows Terminal version Commit ed27737233714dea77877624d1beeb49e2ccd36e ### Windows build number 10.0.19044.1706 ### Other Software _No response_ ### Steps to reproduce 1. Checkout commit ed27737233714dea77877624d1beeb49e2ccd36e or later. 2. Build and run OpenConsole. 3. Perform a few directory listings or something to get a couple of pages into the buffer. 4. Use the scroll wheel to scroll back in the buffer. 5. Use the scroll wheel to scroll forward again. ### Expected Behavior Scrolling should work correctly in both directions. ### Actual Behavior When I attempt to scroll forward, the viewport immediately jumps back to the start of the buffer. I did a git bisect, and it looks like this problem may have been introduced by commit ed27737233714dea77877624d1beeb49e2ccd36e. /cc @lhecker
Author
Owner

@lhecker commented on GitHub (Jun 9, 2022):

I'll check this out as soon as I can. Quite curious that this happens because I did notice this exact bug while I was developing the PR and fixed it.
It can occur when you aren't careful when extracting the wheel delta, as it's stored as a signed 16-bit integer in the high word of the wParam: 4e20a8631c/src/interactivity/win32/windowproc.cpp (L653)

Initially I had replaced all (short) with (til::CoordType) which caused large jumps during scrolling. This appears to be the exact same bug? Wheel deltas (e.g. scrolling down once: int16_t(-3)) gets passed around as unsigned integers (here: uint16_t(65532)). But (til::CoordType)uint16_t(65532) isn't the same as (short)uint16_t(65532)...

@lhecker commented on GitHub (Jun 9, 2022): I'll check this out as soon as I can. Quite curious that this happens because I did notice this exact bug while I was developing the PR and fixed it. It can occur when you aren't careful when extracting the wheel delta, as it's stored as a signed 16-bit integer in the high word of the `wParam`: https://github.com/microsoft/terminal/blob/4e20a8631cbb5b20defe549a0e75bc7719969bee/src/interactivity/win32/windowproc.cpp#L653 Initially I had replaced all `(short)` with `(til::CoordType)` which caused large jumps during scrolling. This appears to be the exact same bug? Wheel deltas (e.g. scrolling down once: `int16_t(-3)`) gets passed around as unsigned integers (here: `uint16_t(65532)`). But `(til::CoordType)uint16_t(65532)` isn't the same as `(short)uint16_t(65532)`...
Author
Owner

@j4james commented on GitHub (Jun 9, 2022):

FYI, I think the issue might be here:
ed27737233/src/host/scrolling.cpp (L145)

We're dividing a short by an unsigned long, which I think is treated as an unsigned division, and that results in a massive positive delta. Previously the ulActualDelta was cast to short here, so it was a signed division.

@j4james commented on GitHub (Jun 9, 2022): FYI, I think the issue might be here: https://github.com/microsoft/terminal/blob/ed27737233714dea77877624d1beeb49e2ccd36e/src/host/scrolling.cpp#L145 We're dividing a short by an unsigned long, which I think is treated as an unsigned division, and that results in a massive positive delta. Previously the `ulActualDelta` was cast to `short` here, so it was a signed division.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17666