Skip to content

Exception when recalling command line with more lines than screen #677

@MaximoTrinidad

Description

@MaximoTrinidad

PSReadLine crashes when doing Up arrow looking for commands that has been previously executed.

Environment data

Provide the output of the following:

& {
    "PS version: $($PSVersionTable.PSVersion)"
    $v = (Get-Module PSReadline).Version
    $m = Get-Content "$(Split-Path -Parent (Get-Module PSReadLine).Path)\PSReadLine.psd1" | Select-String "Prerelease = '(.*)'"
    if ($m) {
        $v = "$v-" + $m.Matches[0].Groups[1].Value
    }
    "PSReadline version: $v"
    if ($IsLinux -or $IsMacOS) {
        "os: $(uname -a)"
    } else {
        "os: $((dir $env:SystemRoot\System32\cmd.exe).VersionInfo.FileVersion)"
    }
    "PS file version: $((dir $pshome\p*[hl].exe).VersionInfo.FileVersion)"
}

PS version: 6.1.0-preview.1
PSReadline version: 1.2
os: Linux mars 4.13.0-38-generic #43-Ubuntu SMP Wed Mar 14 15:20:44 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
PS file version: 

-->

Steps to reproduce or exception report

Use the keyboard up arrow to scan thru previous entered commands.
Exception message:

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

Exception:
System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was -25.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.Internal.TTYConsole.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.PlaceCursor(Int32 x, Int32& y)
   at Microsoft.PowerShell.PSConsoleReadLine.PlaceCursor()
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Render()
   at Microsoft.PowerShell.PSConsoleReadLine.UpdateFromHistory(Boolean moveCursor)
   at Microsoft.PowerShell.PSConsoleReadLine.HistoryRecall(Int32 direction)
   at Microsoft.PowerShell.PSConsoleReadLine.PreviousHistory(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)
-----------------------------------------------------------------------

psreadline_error_2018-04-23_15-40-01

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-DuplicateThere's another issue on the tracker that's pretty much the same thing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions