Skip to content

Copying and pasting a comment raised an exception, until I ran Clear-Host #1081

@rhymeswithmogul

Description

@rhymeswithmogul

Backtrace

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

Environment

PSReadLine: 2.0.0-beta4
PowerShell: 7.0.0-preview.3
OS: Microsoft Windows 10.0.18362
Last 200 Keys

 A s s i g n Spacebar a l e r t s @ C L I E N T D O M A I N Spacebar t o Spacebar t h i s . Enter
 Ctrl+Enter ( G e t - A c c e p t e d D o m a i n Spacebar | Spacebar S e l e c t Spacebar - E x p a n d P r o p e r t y Spacebar D o m a i n N a m e ) Spacebar | Spacebar F o r E a c h - O b j e c t Spacebar { Enter
 Ctrl+Enter Spacebar Spacebar Spacebar Spacebar S e t - M a i l C o n t a c t Spacebar " a l e r t s " Spacebar - E m a i l A d d r e s s e s Spacebar @ { A d d = " a l e r t s @ $ _ " } Spacebar - E r r o r A c t i o n Spacebar S t o p Enter
 Ctrl+Enter } Enter
 Ctrl+Enter

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 'top')
Actual value was 63.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.MoveCursor(Int32 newCursor)
   at Microsoft.PowerShell.PSConsoleReadLine.MoveToLine(Int32 numericArg)
   at Microsoft.PowerShell.PSConsoleReadLine.PreviousLine(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InsertLineAbove(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(PSKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken)

Environment data

PS version: 7.0.0-preview.3
PSReadline version: 2.0.0-beta4
os: 10.0.18362.1 (WinBuild.160101.0800)
PS file version: 7.0.0.0
BufferWidth: 254
BufferHeight: 63

Steps to reproduce or exception report

Get a nice, full scrollback buffer. Then, paste the text ### Assign alerts@CLIENTDOMAIN to this. into PowerShell 7.0.0-preview3. This one block of code always causes the same problem:

### Assign alerts@CLIENTDOMAIN to this.
(Get-AcceptedDomain | Select -ExpandProperty DomainName) | ForEach-Object {
    Set-MailContact "alerts" -EmailAddresses @{Add="alerts@$_"} -ErrorAction Stop
}

There are some more lines of code before that that all ran fine. However, that comment line caused PSReadLine to fail. The code afterwards ran just fine.

Weirdly enough, after running Clear-Host, everything appeared to be fine. I could paste that in all day.

This might (or might not) be a bug in Windows Terminal. It appeared to work fine when I opened PowerShell 7 with pwsh-preview.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-ReproThere is no sufficient information on repro steps.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions