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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/5248
Author: @j4james
Created: 4/5/2020
Status: Merged
Merged: 4/7/2020
Merged by: @undefined

Base: masterHead: fix-altbuffer-ris


📝 Commits (3)

  • e4a6670 Switch back to the main buffer when RIS is received in the alt buffer.
  • 877aaf1 Add unit test to confirm RIS switches back to the main buffer.
  • 8003b52 Update the HardReset doc comment to mention the new behaviour.

📊 Changes

2 files changed (+37 additions, -2 deletions)

View changed files

📝 src/host/ut_host/ScreenBufferTests.cpp (+22 -1)
📝 src/terminal/adapter/adaptDispatch.cpp (+15 -1)

📄 Description

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.


🔄 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/5248 **Author:** [@j4james](https://github.com/j4james) **Created:** 4/5/2020 **Status:** ✅ Merged **Merged:** 4/7/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `fix-altbuffer-ris` --- ### 📝 Commits (3) - [`e4a6670`](https://github.com/microsoft/terminal/commit/e4a6670a42d3db4e6585cda4e9768fc34eca7d64) Switch back to the main buffer when RIS is received in the alt buffer. - [`877aaf1`](https://github.com/microsoft/terminal/commit/877aaf1ce876fe6469251d65834dbc84c0dd0c0d) Add unit test to confirm RIS switches back to the main buffer. - [`8003b52`](https://github.com/microsoft/terminal/commit/8003b5265d99c89323d3713b82c3075fc43c37cc) Update the HardReset doc comment to mention the new behaviour. ### 📊 Changes **2 files changed** (+37 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/host/ut_host/ScreenBufferTests.cpp` (+22 -1) 📝 `src/terminal/adapter/adaptDispatch.cpp` (+15 -1) </details> ### 📄 Description ## 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. --- <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:14:37 +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#26206