PowerShell/ConsoleGuiTools

out-consolegridview clears the console history in Terminal

lexiismadd opened this issue · 9 comments

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

When using out-consolegridview in Terminal, it clears all of the console history other than what was on the terminal window when out-consolegridview is called, meaning you cannot scroll back up past what was on the screen when out-consolegridview is called.
Unsure if this happens in regular PS Core, but it occurs in Terminal v1.17.11461.0 with ocgv 0.7.4.

Expected behavior

Out-ConsoleGridView is called.
User provides some form of input.
OCGV is closed
The console history can still be scrolled back up through (to the actual limit of the console history or what its set to)

Actual behavior

Out-ConsoleGridView is called.
User provides some form of input.
OCGV is closed.
Any console history not in the console window when OCGV is closed is cleared.

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.6
PSEdition                      Core
GitCommitId                    7.3.6
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

0.7.4

Visuals

No response

tig commented

I can't reproduce this. Terminal.Gui used to have behaviors that caused this but that was fixed recently.

Can you please start Windows Terminal with the debug tap turned on and share the ANSI ESC codes that get sent when OCGV closes?

https://github.com/microsoft/terminal/wiki/Enabling-the-debug-tap#:~:text=To%20enable%20the%20debug%20tap%3A%201%20Enable%20debug,the%20input%20and%20output%20sent%20to%20the%20Terminal.

I'm looking to see if ESC[0J, ESC[1J, or ESC[3J is emitted.

Sorry, i'm a bit confused where to add this setting in Windows Terminal:
"debugFeatures": true,

tig commented

Sorry, i'm a bit confused where to add this setting in Windows Terminal: "debugFeatures": true,

Open WT's Settings. On the bottom of the window is:

image

Click that. The .json settings file will open in you editor:

image
tig commented

Terminal.Gui.zip

Please:

Find where Microsoft.PowerShell.ConsoleGuiTools is installed:

$env:PSModulePath -split ';'

In that directory, find Terminal.Gui.dll:
image

Extract Terminal.Gui.dll from the attached zip file and copy it over the one in that directory (you may have to kill all pwsh instances first).

See if it fixes the problem. If it doesn't please capture the WT debug feed again and tell me if you see 1047l or 1049l here:

Close␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣
␛[K␛[69;222H␛[m␛[13;28;13;1;32;1_␛[13;28;13;0;32;1_␛[8;68;133t␛[?1003;1006l␛[?1047l

Hi, no luck I'm afraid. Those codes don't even appear...
Here's the capture again after the updated dll was added:
https://pastes.io/7hw63g7ujz

tig commented

I see

Close␣␣␣␣␣␣␣␣␣. .. ␛[?1003;1006l␛[?1047l

So, for some reason the new dll didn't get picked up. I may have had you copy it to the wrong place.

Can you search your HDD for instances of Terminal.Gui.Dll?

tig commented

@alexisspencer Please grab the latest. This should be fixed. Can you confirm?