question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clear-Host does not clear the entire Windows Terminal after running Lee's rick-roll

See original GitHub issue

Steps to reproduce

iex (New-Object Net.WebClient).DownloadString("http://bit.ly/e0Mw9w")

Expected behavior

After terminating the rick-roll, executing clear-host should clear the entire console but it does not.

Actual behavior

This is my console right after executing clear-host:

image

Notice that there is still text at the bottom of the screen. I don’t see this problem in the PowerShell console. It appears that the script resets what PS thinks is the terminal size. That actually resets the console size but that does not impact the Windows Terminal tab size. Before running the script, PS sees the WIndows Terminal buffer/window size as:

BufferSize            : 121,68
WindowSize            : 121,68

After the script runs (and is aborted by pressing Q)) it is:

BufferSize            : 83,45
WindowSize            : 83,45

It would appear Clear-Host is operating on bad buffer/size data.

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.5
PSEdition                      Core
GitCommitId                    7.2.0-preview.5
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Related: #644

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
rkeithhillcommented, May 21, 2021

@237dmitry ignore the script. This issue is really about why the following breaks Clear-Host functionality in Windows Terminal:

dir C:\Windows
$host.UI.RawUI.WindowSize = New-Object System.Management.Automation.Host.Size 83,45
Clear-Host
1reaction
rkeithhillcommented, May 21, 2021

Yup, a simple repro is to dump a bunch of text to the terminal (dir ~) and then execute:

dir C:\Windows
$host.UI.RawUI.WindowSize = New-Object System.Management.Automation.Host.Size 83,45
Clear-Host
Read more comments on GitHub >

github_iconTop Results From Across the Web

Clear Screen in PowerShell and Command Line without ...
In using the clear command, the screen clears. Totally. I no longer have access to any of the stuff that was previously on...
Read more >
How to clear the entire terminal (PowerShell)
right click on the powershell button, then select clear, when you are at the command window, type "clear" command, to clear the terminal...
Read more >
Windows Terminal Troubleshooting
This guide addresses some of the common errors and obstacles you may encounter when using Windows Terminal.
Read more >
Windows Terminal tips and tricks
In this page, you will find tips and tricks to help improve your Windows Terminal experience.
Read more >
Custom actions in Windows Terminal
Quit. This closes all open terminal windows. A confirmation dialog will appear in the current window to ensure you'd like to close all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found