Skip to content

Long here-strings scroll on every keypress #962

Closed

Description

@AikenBM

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.

Activity

  1. AikenBM commented on Aug 14, 2019

    @AikenBM
    Author

    To clarify, this scrolling issue happens on any long multi-line entry, it's just easiest to reproduce with a long here-string. A long list of values separated by a comma and a line break, or a really long ForEach-Object script block would experience the same scrolling problem.

  2. vexx32 commented on Aug 14, 2019

    @vexx32

    From Dongbo Wang (@daxian-dbw)'s examples in #979, it looks like this should be sorted out in the scope of that PR?

  3. daxian-dbw commented on Aug 14, 2019

    @daxian-dbw
    Member

    #979 should mitigate the issue in cases that editing happens at relatively the end part of the long text.

  4. daxian-dbw commented on Sep 13, 2019

    @daxian-dbw
    Member

    The specific behavior reported by this issue was fixed by #979

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions