Psreadline: Error on PageUp/PageDown keys

Created on 4 Jun 2018  ·  12Comments  ·  Source: PowerShell/PSReadLine

Environment data

PS version: 6.1.0-preview.2
PSReadline version: 2.0.0-beta1
os: Linux localhost.localdomain 4.16.13-300.fc28.x86_64 #1 SMP Wed May 30 14:31:00 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
PS file version: 

This is Fedora 28, using the terminal Konsole.

Steps to reproduce or exception report

Just hit PageUp or PageDown

Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 1 Keys:
 PageUp

Exception:
System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.ConsolePal.SetWindowPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.ScrollDisplayUp(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------
Resolution-Duplicate

All 12 comments

On an unrelated note, if there is anything bound to Control+C, that bind won't work, so I can't do CopyOrCancelLine.

On your unrelated note, that should be fixed in 2.0.0-beta2 - but you need to specify Ctrl+c instead of Ctrl+C (lower case c.)

I meant beta2 (the link was correct).

I come from the Home/End buttons not working issue and it still doesn't work for me. I tried installing the latest Beta, but I'm not sure if it's gone right or not. I am using vanilla PS Core on both my local box and my remote Ubuntu.

Home/End is working fine locally, both in Windows and in WSL. They also work remotely if using bash, or pwsh without PSReadline. It only breaks when PSReadline is enabled through ssh. I am using the latest build of Win32-OpenSSH.

To be sure, how do you install the latest beta of PSReadline? I tried

Install-Module -Name PSReadLine -RequiredVersion 2.0.0-beta3 -AllowPrerelease -Scope CurrentUser

But if I check later

Get-Module PSReadLine -ListAvailable -all


    Directory: C:\Users\mnagy\Documents\PowerShell\Modules

ModuleType Version    Name                                PSEdition ExportedCommands
---------- -------    ----                                --------- ----------------
Script     2.0.0      PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLine…
Script     0.0        PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineOption, Set-PSReadLineKeyHand…

    Directory: C:\kellekek\microsoft\powershell\6.2.0\Modules

ModuleType Version    Name                                PSEdition ExportedCommands
---------- -------    ----                                --------- ----------------
Script     2.0.0      PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLine…
Script     0.0        PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLineOption, Set-PSReadLineKeyHand…

How can I check what version is loaded when Powershell starts? And what are the 0.0 versions?

I can also repro this in iTerm2 on macOS and on Ubuntu.

After it does crash, I can no longer use Ctrl+C until after I hit ENTER

I suppose the actual problem is with the ScrollDisplay* functions:

PageDown      ScrollDisplayDown Scroll the display down one screen
PageUp        ScrollDisplayUp   Scroll the display up one screen

I may not have been clear. There is no version of ssh client-server (Win32-OpenSSH or native), PSReadline, PowerShell and local-remote OS in which this would work. It seems like a very deterministic issue when using PS through an SSH connection. It makes using PS very annoying.

I'm also seeing this on 7.0.0 preview 1 with PSReadLine 2.0.0-beta4

I can also repro this in iTerm2 on macOS and on Ubuntu.

After it does crash, I can no longer use Ctrl+C until after I hit ENTER

I suppose the actual problem is with the ScrollDisplay* functions:

PageDown      ScrollDisplayDown Scroll the display down one screen
PageUp        ScrollDisplayUp   Scroll the display up one screen

is there an interim bandaid to disable the pageup/pagedown key bindings ? I am also having this problem.

@frasercarter You can add this to your $profile:

Remove-PSReadLineKeyHandler -Chord ([System.ConsoleKey]::PageUp)
Remove-PSReadLineKeyHandler -Chord ([System.ConsoleKey]::PageDown)

Or more succinctly:

Remove-PSReadLineKeyHandler -Chord PageUp
Remove-PSReadLineKeyHandler -Chord PageDown

With this environment

PS version: 5.1.17763.592
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: 199
BufferHeight: 9001

I get a similar problem but not the same exception.

Exception:
System.IO.IOException: The parameter is incorrect.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.Console.SetWindowPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.ScrollDisplayDown(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

Running the suggested Remove-PSReadLineKeyHandler commands appears to stop this from happening.

Close as a duplicate of #1016

Was this page helpful?
0 / 5 - 0 ratings