Windows build number: 10.0.18362.356
Windows Terminal version (if applicable): 0.5.2762.0
Any other software? less pager (https://chocolatey.org/packages/Less)
Open PowerShell Tab
less <somefile> will show the file in foreground color
gci
less <somefile> will show the file in black color
<somefile> should be shown in foreground color
Somehow, after "gci" the file is shown in black. This does not happen with Cmd (note: at least when I tried to reproduce it, but I believe it had happened previously with cmd as well) and it doesn't happen in PowerShell or Cmd standalone (same note applies).
This doesn't happen when you just use powershell directly (not inside Windows Terminal,) right?
Yes, indeed.
This is likely some combination of #2661 and #293.
It's a little bit more insidious than that. It looks like less is reading the color of the cell under the cursor when it's launched and using that as the default text color. Now, as for why it's getting 0x00 (black on black) from that cell in Windows Terminal where it's not in the legacy Console Host... that's a very good question.
Thanks for investigating!
It may be related to Powershell. With cmd the bug doesn't occur. However, when I run powershell from this cmd, call gci (which is important, otherwise it seems to work) subsequent calls to less show letters in black again. Even after exiting from this instance of PowerShell! Maybe it's something that gci does? Edit: you're right - it's not gci, it occurs after output reaches the bottom of the screen somehow - nevertheless it does this only in PowerShell for me. And it does not return, even after the screen is cleared.
What's strange now: PowerShell 7 Preview 5 (did not test with 4) shows the same behaviour - outside Windows Terminal (in its own Conhost or whatever).
Yanking the triage tag off this. It's interesting that the cell _less_ is reading is different inside/outside of terminal and with powershell core 6/7/windows powershell 5.
Issue maybe releated to this one:
Output is invisible when run under PowerShell Core #10
More Details I Found:
The color is rendered correctly if I pressing Ctrl+L before using less.
And then problem occurs if I typing on the bottom line of the Terminal (In either Windows PowerShell or PowerShell Core, by hitting enter until I can type on the bottom).
It may be related to Powershell. With cmd the bug doesn't occur. However, when I run
powershell
I'm seeing this issue in cmd, using the less.exe from UnxUtils.
The bug happens any time after the either the cursor has been at the bottom of the screen, or the screen has been cleared (cls). The only time it doesn't happen is when I'm in a new terminal window and haven't yet scrolled or cleared it.
Using Terminal 0.6.2951.0, less.exe from http://unxutils.sourceforge.net/.
It notice it doesn't happen on my laptop. I looked for differences between them, and determined that it's due to my prompt:
PROMPT=$_$E[m$E[32m[ $D $T %COMPUTERNAME%$E\$S$E[92m$P $E[32m]$E[90m$_$E[90m$G$E[m
(Just started using Terminal and hadn't got around to configuring the prompt on my laptop yet.)
If I change the prompt to avoid reset ($E[m) and always explicitly set a color instead, I don't see the bug:
PROMPT=$_$E[32m[ $D $T %COMPUTERNAME%$E\$S$E[92m$P $E[32m]$E[90m$_$E[90m$G$E[37m
Most helpful comment
I'm seeing this issue in cmd, using the
less.exefrom UnxUtils.The bug happens any time after the either the cursor has been at the bottom of the screen, or the screen has been cleared (
cls). The only time it doesn't happen is when I'm in a new terminal window and haven't yet scrolled or cleared it.Using Terminal 0.6.2951.0,
less.exefrom http://unxutils.sourceforge.net/.It notice it doesn't happen on my laptop. I looked for differences between them, and determined that it's due to my prompt:
(Just started using Terminal and hadn't got around to configuring the prompt on my laptop yet.)
If I change the prompt to avoid reset (
$E[m) and always explicitly set a color instead, I don't see the bug: