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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5630
Author: @zadjii-msft
Created: 4/28/2020
Status: Merged
Merged: 4/29/2020
Merged by: @undefined

Base: masterHead: dev/migrie/b/i-have-no-idea-what-this-is


📝 Commits (3)

  • cfeaf54 Well this is definitely wrong
  • ba447fb Adding a test for this was sure the roller coaster
  • 84b01c2 good bot

📊 Changes

5 files changed (+195 additions, -4 deletions)

View changed files

📝 src/cascadia/TerminalCore/Terminal.cpp (+7 -3)
📝 src/cascadia/TerminalCore/Terminal.hpp (+2 -0)
src/cascadia/UnitTests_TerminalCore/TerminalAndRendererTests.cpp (+177 -0)
📝 src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp (+8 -1)
📝 src/cascadia/UnitTests_TerminalCore/UnitTests.vcxproj (+1 -0)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/5630 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 4/28/2020 **Status:** ✅ Merged **Merged:** 4/29/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/migrie/b/i-have-no-idea-what-this-is` --- ### 📝 Commits (3) - [`cfeaf54`](https://github.com/microsoft/terminal/commit/cfeaf54cca990c768d6889963fc8a10bfbc1179d) Well this is definitely wrong - [`ba447fb`](https://github.com/microsoft/terminal/commit/ba447fb95f3dcf1fce78091f316b829226da644f) Adding a test for this was sure the roller coaster - [`84b01c2`](https://github.com/microsoft/terminal/commit/84b01c24182be5235bf603431135943f92356d0f) good bot ### 📊 Changes **5 files changed** (+195 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+7 -3) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+2 -0) ➕ `src/cascadia/UnitTests_TerminalCore/TerminalAndRendererTests.cpp` (+177 -0) 📝 `src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp` (+8 -1) 📝 `src/cascadia/UnitTests_TerminalCore/UnitTests.vcxproj` (+1 -0) </details> ### 📄 Description ## 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:15:49 +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#26396