[PR #5248] Make RIS switch back to the main buffer #26211

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

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

State: closed
Merged: Yes


Summary of the Pull Request

If we receive a Reset to Initial State (RIS) sequence while in the alternate screen buffer, we should be switching back to the main buffer. This PR fixes that behavior.

PR Checklist

  • Closes Right click Terminal taskbar item: 'Run as Administrator' (#3685)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

I've added a condition at the start of the AdaptDispatch::HardReset method to check whether we're using the alt buffer, and if so, call the ConGetSet::PrivateUseMainScreenBuffer API to switch back to the main buffer.

Calling AdaptDispatch::UseMainScreenBuffer would probably be neater for this, but it would also attempt to restore the cursor state, which seems pointless when we're in the process of resetting everything anyway.

Validation Steps Performed

I've added a screen buffer test to confirm that the RIS sequence does actually switch back to the main buffer. I've also manually confirmed that the test case in issue #3685 does now behave as expected.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/5248 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request If we receive a _Reset to Initial State_ (`RIS`) sequence while in the alternate screen buffer, we should be switching back to the main buffer. This PR fixes that behavior. ## PR Checklist * [x] Closes #3685 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [x] Tests added/passed * [ ] Requires documentation to be updated * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Detailed Description of the Pull Request / Additional comments I've added a condition at the start of the `AdaptDispatch::HardReset` method to check whether we're using the alt buffer, and if so, call the `ConGetSet::PrivateUseMainScreenBuffer` API to switch back to the main buffer. Calling `AdaptDispatch::UseMainScreenBuffer` would probably be neater for this, but it would also attempt to restore the cursor state, which seems pointless when we're in the process of resetting everything anyway. ## Validation Steps Performed I've added a screen buffer test to confirm that the `RIS` sequence does actually switch back to the main buffer. I've also manually confirmed that the test case in issue #3685 does now behave as expected.
claunia added the pull-request label 2026-01-31 09:14:39 +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#26211