Inputting long values with Read-Host eventually triggers an exception
See original GitHub issueSystem Details
System Details Output
### VSCode version: 1.47.2 17299e413d5590b14ab0340ea477cdd86ff13daf x64
### VSCode extensions:
ms-vscode.powershell-preview@2020.6.1
### Modules
I have PSReadLine 2.1.0 beta2 and it's checked in the extension settings
### PSES version: 2.2.0.0
### PowerShell version:
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Description
Typing or pasting long values and submitting to Read-Host
prompts eventually trigger a System.ArgumentOutOfRangeException
System.Exception: Prompt failed, check inner exception for details
---> 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 45.
This is related to #702
Expected Behaviour
The behavior should be consistent / no exception thrown
Actual Behaviour
I’ve observed that visually once the console output fills up the exception will be thrown on the next Read-Host
try. Here’s a screencap I took. The first 2 runs of the script are fine but the 3rd throws the exception. If afterwards I run Clear-Host
and try again it does not throw the exception. If I run Clear-Host
before each script run (or include Clear-Host
at the top of my script) I can consistently get it to behave correctly.
I also tried (instead of pasting values) seeing what would happen if I manually typed long values that wrap. It required me to do this many times until the height of the console output reached whatever height value this is – then the exception occurred.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
Indeed, it’s been a while. I just tried to reproduce this and was unable to. Now if only the Azure PowerShell console didnt overwrite console output inline randomly… but I think we can close this one.
Thanks @compelx looking at your stack trace, it looks like Read-Host is calling into a legacy version of our PSReadLine experience in the integrated terminal, we hope that we can resolve this as a part of the work happening in https://github.com/PowerShell/PowerShellEditorServices/issues/1295