PowerShell / PSReadLine

A bash inspired readline implementation for PowerShell
BSD 2-Clause "Simplified" License
3.76k stars 298 forks source link

Terminal bug report telling me to tell github #4252

Closed SomeKindOfGeek closed 3 weeks ago

SomeKindOfGeek commented 3 weeks ago

Prerequisites

Exception report

Last 200 Keys:
 a r t - s l e e p Space - s e c o n d s Space 3 Enterolor -Red
 Space w r i t e - h o s t Space " R U N . . . Space > : ) " Space - F o r e g r o u n d C o l o r Space - R e d Enter
 Space } Enter
 Space } Enter = [int](read-Host "ENTER PASSWORD: $x x $y " ) -ForegroundColor -Blue
 Space h e l l o 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 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 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 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 UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow
>>  Write-Host "FALSE ALARM" -ForegroundColor -Green
Exception:sleep -seconds 0.7
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 -1.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)egroundColor -Blue
   at Microsoft.PowerShell.PSConsoleReadLine.MoveCursor(Int32 newCursor)
   at Microsoft.PowerShell.PSConsoleReadLine.MoveToLine(Int32 numericArg)
   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)

Screenshot

n/a

Environment data

PS Version: 5.1.19041.5007
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.0.0-beta2
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 30

Steps to reproduce

function hello { clear-Host $y = get-random -Minimum 6 -Maximum 15 $x = $number = get-random -Minimum 6 -Maximum 15 $product = $x * $y

Write-Host "SECURITY BREACH DECTECTED" ForegroundColor -Red start-sleep -seconds 1

$userInput = int -ForegroundColor -Blue start-sleep -seconds 0.5 write-host "3..." ForegroundColor -Green start-sleep -seconds 0.5 write-host "2..." ForegroundColor -Green start-sleep -seconds 0.5 write-host "1..." ForegroundColor -Green

if ($userInput -eq $product) { clear-host Write-Host "FALSE ALARM" -ForegroundColor -Green start-sleep -seconds 0.7 write-host "LOCKDOWN DEACTIVATING" -ForegroundColor -Green

} else { clear-host write-host "Hello, I am Justin Treudo. I SEE YOU..." -ForegroundColor -Blue start-sleep -seconds 3 write-host "RUN... >:)" -ForegroundColor -Red } } hello

Expected behavior

It should just give you an error message

Actual behavior

It gives me an error message, and I am unable to edit the code

daxian-dbw commented 3 weeks ago

You are using a very old version of the PSReadLine module (shipped in-box with PowerShell) and the issue should've been fixed in newer versions. Please upgrade to the 2.3.5 version of PSReadLine from PowerShell Gallery. See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.