Skip to content

Multi-line prompt triggers exception #843

Closed

Description

@perennialmind

Environment data

PSReadline version: 2.0.0-beta3
os: 10.0.17134.1 (WinBuild.160101.0800)
PS file version: 6.1.0

Steps to reproduce or exception report

Define a multi-line prompt, with embedded linebreak of "`n", "`n`r", or [System.Environment]::NewLine. Start typing pretty much anything. if will do. Calling Set-PSReadlineOption -ExtraPromptLineCount 1 before or after did not affect the outcome.

PS C:\> Set-PSReadlineOption -ExtraPromptLineCount 1
PS C:\> function prompt { "[$(Get-Location)\]`n`r$("+"*(Get-Location -Stack).Count)>" }
[C:\\]
>i

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

Last 82 Keys:

 f u n c t i o n Space p r o m p t Space { Space " [ $ ( G e t - L o c a t i o n ) \ ] ` n ` r $ ( " + " * ( G e t - L o c a t i o n Space - S t a c k ) . C o u n t ) > " Space } Enter
 i f

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: left
Actual value was -1.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(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, CancellationToken cancellationToken)

[C:\]

Activity

  1. perennialmind commented on Jan 9, 2019

    @perennialmind
    Author

    My pwsh was out of date, but testing with Powershell 6.1.1 shows the same behavior.

    PS version: 6.1.1
    PSReadline version: 2.0.0-beta3
    os: 10.0.17134.1 (WinBuild.160101.0800)
    PS file version: 6.1.1

  2. gforsman commented on Jan 31, 2019

    @gforsman

    I hit this with just a long prompt that wrapped because the CWD I was in was long. It happened that prompt ended near the right edge of the console, and the cursor was appearing on its own line.

    I entered a command to run to see the output.
    Then I UPARROW to edit the command, HOME to move to the beginning of the line, and typed $ as to do a "$t=" to capture the output the command to a variable.

    I widened the console window and this did not occur with the same prompt and command sequence.

  3. daxian-dbw commented on Sep 13, 2019

    @daxian-dbw
    Member

    Fixed by #979 and #967

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

    OutOfRangeIssues relating to System.ArgumentOutOfRangeException

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions