[PR #13324] [MERGED] Make sure conpty is flushed before clearing scrollback #29476

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/13324
Author: @j4james
Created: 6/18/2022
Status: Merged
Merged: 6/20/2022
Merged by: @DHowett

Base: mainHead: fix-conpty-cls


📝 Commits (1)

  • 1097332 Make sure conpty renderer is flushed before clearing scrollback.

📊 Changes

2 files changed (+6 additions, -0 deletions)

View changed files

📝 src/host/_output.cpp (+3 -0)
📝 src/host/getset.cpp (+3 -0)

📄 Description

Summary of the Pull Request

When you execute a cls in the cmd shell, or Clear-Host in
PowerShell, we have a pair of shims that attempt to detect those
operations and forward an ED3 sequence to conpty to clear the
scrollback.

If there was a linefeed at the bottom of the viewport immediately
prior to those functions being called, that event might still be
pending, and only forwarded to conpty after the ED3. The result
then is a line pushed into the scrollback that shouldn't be there.

This PR tries to avoid that situation by forcing the renderer to
flush before the ED3 sequence is sent.

References

The cls and Clear-Host shims were originally added in PR #5627.

PR Checklist

Validation Steps Performed

I've manually tested in PowerShell with echo Hello; Clear-Host (this
is the only way I could reliably reproduce the original problem), and in
the cmd shell with cls. Both cases are now working 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/13324 **Author:** [@j4james](https://github.com/j4james) **Created:** 6/18/2022 **Status:** ✅ Merged **Merged:** 6/20/2022 **Merged by:** [@DHowett](https://github.com/DHowett) **Base:** `main` ← **Head:** `fix-conpty-cls` --- ### 📝 Commits (1) - [`1097332`](https://github.com/microsoft/terminal/commit/1097332610de6062b957a070ca0c0fc308dbc8cc) Make sure conpty renderer is flushed before clearing scrollback. ### 📊 Changes **2 files changed** (+6 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/host/_output.cpp` (+3 -0) 📝 `src/host/getset.cpp` (+3 -0) </details> ### 📄 Description ## Summary of the Pull Request When you execute a `cls` in the cmd shell, or `Clear-Host` in PowerShell, we have a pair of shims that attempt to detect those operations and forward an `ED3` sequence to conpty to clear the scrollback. If there was a linefeed at the bottom of the viewport immediately prior to those functions being called, that event might still be pending, and only forwarded to conpty after the `ED3`. The result then is a line pushed into the scrollback that shouldn't be there. This PR tries to avoid that situation by forcing the renderer to flush before the `ED3` sequence is sent. ## References The `cls` and `Clear-Host` shims were originally added in PR #5627. ## PR Checklist * [x] Closes #5770 * [x] Closes #13320 * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. * [ ] Schema 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 ## Validation Steps Performed I've manually tested in PowerShell with `echo Hello; Clear-Host` (this is the only way I could reliably reproduce the original problem), and in the cmd shell with `cls`. Both cases are now working 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:35:09 +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#29476