-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear-Host sometimes leaves a line at the top of the screen #5770
Comments
I can't reproduce this with any version of Windows PowerShell or PowerShell Core. Can you share your |
For proof sake // To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles": [
{
// Make changes here to the powershell.exe profile
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"name": "Windows PowerShell",
"commandline": "powershell.exe",
"hidden": false
},
{
// Make changes here to the cmd.exe profile
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "cmd",
"commandline": "cmd.exe",
"hidden": false
},
{
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell 7",
"source": "Windows.Terminal.PowershellCore"
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
{
"guid": "{a3a2e83a-884a-5379-baa8-16f193a13b21}",
"hidden": false,
"name": "PowerShell 7 Preview",
"source": "Windows.Terminal.PowershellCore"
}
],
// Add custom color schemes to this array
"schemes": [],
// Add any keybinding overrides to this array.
// To unbind a default keybinding, set the command to "unbound"
"keybindings": []
} |
Actually this only happens in Windows Powershell. PowerShell 7 is good for me. |
Okay this is really strange. Does it reproduce if you make the Windows PowerShell window one line taller, and then one line shorter, before you try it? I wonder if it disagrees about how tall the screen is ... |
It doesn't matter. Tried to make it very small or very large. Always 1 line above prompt is there. |
Hey so we saw something kinda similar over in #5753. Can you share the output of
? Do you have any customizations you've made to your powershell prompt in your |
code $profile Clear-Host
Write-Color "Windows PowerShell"
Write-Color "Copyright (C) Microsoft Corporation. All rights reserved." -LinesAfter 1
#Write-Host "Windows PowerShell"
#Write-Host "Copyright (C) Microsoft Corporation. All rights reserved."
#Write-Host
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
} |
It may be useful -> |
Even on a clean install of both PowerShell 7 and Windows Terminal, I can't clear the history on PowerShell or PowerShell 7. It's still there if you scroll up. (See my unresolved, but strangely closed #4461) Even the command for cmd to clear PS's history isn't respected in Windows Terminal. |
That issue was closed because it was a duplicate of another issue, issue #3126, which was fixed in #5627, which was released in v0.11.1251.0. @jrd-lewis are you still seeing this in v0.11.1251.0? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@cawoodm regarding VSCode you need to update PowerShell and then check settings It was fixed long time ago :-) |
Also, when the changes made to the pseudoconsole for Clear-Host get integrated into a Windows build, VSCode will see the same benefits 😄 |
Well you just need to fix my PS 5.1 terminal and you're good to go :-p |
Would you mind sharing a "debugging transcript"? Careful - this will capture all your input. First, open "debugFeatures": true Then hold down Left Alt and Right Alt when opening a new Windows PowerShell tab. It'll look like this when it's working: Reproduce the issue. Capture the transcript from the split pane. If there's any sensitive input or output, feel free to reach out to me through the e-mail address on my GitHub profile. |
|
Same issue for me. It doesn't look like a terminal issue. It also causes in windows powershell. |
I've just been looking at this issue, and while I can't reproduce the problem if I do But what appears to be happening is there's a linefeed that triggers an One simple way to fix this is to reset the |
## 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.
## 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. (cherry picked from commit 08c2f35) Service-Card-Id: 83388911 Service-Version: 1.14
🎉This issue was addressed in #13324, which has now been successfully released as Handy links: |
🎉This issue was addressed in #13324, which has now been successfully released as Handy links: |
I am aware of closed issue Clear-Host does not clear the previous content (Powershell) #3126 implemented in Implement a pair of shims for
cls
,Clear-Host
in conpty mode #5627 but it didn't resolve this issue totally.Environment
Steps to reproduce
Open Terminal, type Get-Help, Type Clear-Host, Scroll up
Typing
Get-Process
,Clear-Host
shows a similar issue.Expected behavior
Clear-Host should always clear screen without any scrollback possible.
Actual behavior
Some stuff is left (1 line at the top).
The text was updated successfully, but these errors were encountered: