[PR #5630] Clamp the new rows scrolling value to a positive number #26401

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

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

State: closed
Merged: Yes


Summary of the Pull Request

This PR clamp the "new rows" scrolling value to a positive number. We can't create a negative number of new rows. It also adds a test.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

The origin of this bug is that as newlines are emitted, we'll accumulate an enormous scroll delta into a selection region, to the point of overflowing a SHORT. When the overflow occurs, the Terminal would fail to send a NotifyScroll() to the TermControl hosting it.

For this bug to repro, we need to:

  • Have a sufficiently large buffer, because each newline we'll accumulate a delta of (0, ~bufferHeight), so (bufferHeight^2 + bufferHeight) > SHRT_MAX
  • Have a selection

Validation Steps Performed

  • Dustin verified this actually
  • Created a new insane test case
**Original Pull Request:** https://github.com/microsoft/terminal/pull/5630 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This PR clamp the "new rows" scrolling value to a positive number. We can't create a negative number of new rows. It also adds a test. ## References ## PR Checklist * [x] Closes #5540 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments The origin of this bug is that as newlines are emitted, we'll accumulate an enormous scroll delta into a selection region, to the point of overflowing a `SHORT`. When the overflow occurs, the `Terminal` would fail to send a `NotifyScroll()` to the `TermControl` hosting it. For this bug to repro, we need to: - Have a sufficiently large buffer, because each newline we'll accumulate a delta of (0, ~bufferHeight), so (bufferHeight^2 + bufferHeight) > SHRT_MAX - Have a selection ## Validation Steps Performed * Dustin verified this actually * Created a new insane test case
claunia added the pull-request label 2026-01-31 09:15:51 +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#26401