Description
After updating to PowerShell Core 6.2.1, I've noticed an issue with how PSReadLine handles multiline entry in both Windows PowerShell 5.1 and PowerShell Core 6. When entering a long multi-line entry in a here-string, PSReadLine scrolls to the first line of the prompt and then scrolls to the end on each keypress. On very long entries, this can take extremely long to scroll between each keypress.
Environment data
PS version: 6.2.1
PSReadline version: 2.0.0-beta3
os: 10.0.17763.1 (WinBuild.160101.0800)
PS file version: 6.2.1.0
BufferWidth: 200
BufferHeight: 9001
PS version: 5.1.17763.503
PSReadline version: 2.0.0-beta2
os: 10.0.17763.1 (WinBuild.160101.0800)
PS file version: 10.0.17763.1 (WinBuild.160101.0800)
BufferWidth: 200
BufferHeight: 3000
I'm unsure how to update either of these; I don't see that beta4 has a binary release. I'm not able to install Powershell Core 7 preview, unfortunately, so I cannot test that. Major version increments have to be approved even for testing on my systems.
Steps to reproduce or exception report
First, create a long multiline string.
On PowerShell 5:
# Set a long multiline string
1..1000 | Set-Clipboard
On PowerShell Core 6 with the ClipboardText module:
# Set a long multiline string
1..1000 | Set-ClipboardText
In reality, this list of values or long string would come from outside of Powershell entirely; this is just a convenient analog.
Now, start writing a command with a here-string command and paste the text from your clipboard. Powershell will scroll to the end of the entry.
PS C:\> $x = -split @'
>> 1
>> 2
>> 3
...
>> 998
>> 999
>> 1000
That's all fine.
Now, try closing the here-string and piping it to a command:
>> 998
>> 999
>> 1000
>> '@ | Get-Random -Count 25
Every time you press a key, Powershell will jump back up 1000 lines and scroll the output back down. If you start typing normally, you can't even read the screen because it's scrolling so wildly. Arrow keys work normally, but selecting text with arrow keys causes the scrolling issue again.
The only workaround I've found is to disable PSReadLine with Remove-Module PSReadline
. I don't remember this happenning with PSReadLine 1.2.