Skip to content

System.ArgumentOutOfRangeException even on 2.0.0-beta2 #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
VimalShekar opened this issue Nov 10, 2019 · 3 comments
Closed

System.ArgumentOutOfRangeException even on 2.0.0-beta2 #1170

VimalShekar opened this issue Nov 10, 2019 · 3 comments

Comments

@VimalShekar
Copy link

VimalShekar commented Nov 10, 2019

I still see the error with PSReadline version: 2.0.0-beta5

Environment:
PS version: 5.1.18362.145
PSReadline version: 2.0.0-beta5
os: 10.0.18362.356 (WinBuild.160101.0800)
PS file version: 10.0.18362.356 (WinBuild.160101.0800)
HostName: ConsoleHost
BufferWidth: 219
BufferHeight: 29

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 -38.
at System.Console.SetCursorPosition(Int32 left, Int32 top)
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(Nullable1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

Steps to reproduce or exception report

Copy some thing big and paste it into the integrated terminal of Visual studio code.
All I had to do was copy the below script that grabs the environment data, This was sufficient to break PSReadline

&{
$hostName = $Host.Name
if ($hostName -eq "ConsoleHost" -and (Get-Command Get-CimInstance -ErrorAction SilentlyContinue)) {
$id = $PID
$inWindowsTerminal = $false
while ($true) {
$p = Get-CimInstance -ClassName Win32_Process -Filter "ProcessId Like $id"
if (!$p -or !$p.Name) { break }
if ($p.Name -eq "WindowsTerminal.exe") { $inWindowsTerminal = $true; break }
$id = $p.ParentProcessId
}
if ($inWindowsTerminal) { $hostName += " (Windows Terminal)" }
}
"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: $($name = if ($PSVersionTable.PSEdition -eq "Core") { "pwsh.dll" } else { "powershell.exe" }; (dir $pshome$name).VersionInfo.FileVersion)"
"HostName: $hostName"
"BufferWidth: $([console]::BufferWidth)"
"BufferHeight: $([console]::BufferHeight)`n"
}

@msftrncs
Copy link
Collaborator

@VimalShekar, Your environment states 'ConsoleHost', but your description mentions VS Code. Can you clarify this? Can you also clarify your environment in VS Code? It may not be the same as when you collected the environment in ConsoleHost.

The signature of this exception exactly matches one fixed in beta 5. I cannot repeat the exception at this time. I also note that the exception report claims that ReallyRender attempted to set the cursor position to -38, with an environment of 29 lines, and a sample paste that is only 33 lines long.

If you can reproduce this, can you get the environment, and the exact exception report including the previous 200 keys (minus any privacy items), and report what you were doing at the time, so the scenario can be matched up better?

@daxian-dbw
Copy link
Member

daxian-dbw commented Nov 11, 2019

@VimalShekar Are you using the PowerShell Preview VSCode extension? Only the PowerShell Preview extension supports working with PSReadLine, the PowerShell extension doesn't work with PSReadLine.
I cannot reproduce the this in PowerShell Preview extension with 2.0.0-beta5 of PSReadLine.

@daxian-dbw
Copy link
Member

@VimalShekar I will close this issue for now. Note that PSReadLine is only available in the preview powershell-vscode extension, see PowerShell/vscode-powershell#1793.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants