-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Missing lines in the output when using with PowerShell #5700
Comments
This happens on Terminal Preview + PowerShell, but not on Terminal Preview + cmd or on standard Windows terminal + PowerShell. It's not just a rendering glitch. When the output is copied to the clipboard, it still misses a line. When trying it with a window of a different height, a different line is missing. |
I see similar results running the PowerShell equivalent of the Python script. 1..30 | foreach { write "$_ $("*"*20)";Write ("-"*20)} The first time I run the command I can scroll up and see results as expected. But when I run it a second time and scroll up to the first results I'm missing a line. When running in PowerShell 7 it is even worse as sometimes I'm missing half the of the previous output. But that may be a quirk when running Clear-Host. I get similar results with a shorter number of iterations like 15. I also tested with a command like Get-Process. I ran the command, then copied and pasted the results into the PowerShell ISE to make it easy to see line numbers. I had 300 lines. Then I ran Get-Process again and scrolled up to the previous result to again copy and paste. Now I only get 299 lines. This is in line with the other testing. |
This sounds weirdly like this old PSReadline issue where it was telling us to “scroll the screen” instead of “insert a new line” before it displayed the prompt ... If you just hold down Enter at your powershell prompt, does it stop putting your prompt into the scrollback at some point? |
@DHowett-MSFT , if I keep pressing Enter in a fresh PowerShell tab, the prompt appears every time. But the output buffer stops growing once it occupies exactly one screen and the prompt is at the very bottom. So there is never a scroll bar. Few more presses make the initial PowerShell message disappear. Past this point, every time I press Enter, nothing on screen changes but for a small redraw flicker. I don't know if it's because one of the old lines disappears, or because the new prompt doesn't appear. |
So, alright, this one is a somewhat sad story.
Yep. PowerShell that comes with Windows ships with a version of PSReadline that's frozen in time. It was built somewhere between 2.0.0-beta2 and 2.0.0-beta3. Unfortunately, that means it doesn't have the fix for PowerShell/PSReadLine#724. NOTE: it's hard to tell, because Because it doesn't have the fix for PSReadline 724, when it prints a new line at the bottom of the screen, it tells the whole console to "shift your contents up by one line". This means that the console window Terminal is talking to needs to redraw 100% of the content on the screen, because it doesn't currently support the "scroll" operation (that's another can of worms 😄). It moves to the top line, and overwrites it with the line below it . . . and then does that until it gets to the bottom line, which it erases. The top line is destroyed instead of being placed into the scrollback. If PSReadline just emitted a newline character, the topmost line would be pushed up into the scrollback, and the new bottom line would be naturally created blank with the appropriate attributes. This is fixed in PowerShell 6+ and 7. Because the inbox Windows PowerShell is stuck at 5.1, with an outdated version of PSReadline, this may never get fixed -- but there isn't too much that Terminal can do about it. It happens in VSCode and WSL as well, for the same reason. @zadjii-msft: is this something that we could shim? Now that we've cracked that cask of ale open, I want to drink from it all the time 😉 For now, resolving External. |
@DHowett-MSFT , if old PowerShell and Windows are to blame, why doesn't this happen when old PowerShell is used in the standard Windows terminal instead of Terminal Preview? |
in case anybody else got here and was a little confused by the "this may never get fixed" statement made earlier, @DHowett-MSFT is talking about Powershell 5.1. You can still install Powershell 7, but note that it will co-exist alongside Powershell 5.1. So you will have to set Windows Terminal to use Powershell 7 by default if you don't want to worry about the missing lines issue ever again. |
Environment
Steps to reproduce
python hello.py
python hello.py
Expected behavior
Actual behavior
The text was updated successfully, but these errors were encountered: