Skip to content
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

ArgumentOutOfRange Exception if command accepted when last line of buffer is full #1181

Closed
msftrncs opened this issue Nov 14, 2019 · 2 comments · Fixed by #1182
Closed

ArgumentOutOfRange Exception if command accepted when last line of buffer is full #1181

msftrncs opened this issue Nov 14, 2019 · 2 comments · Fixed by #1182

Comments

@msftrncs
Copy link
Collaborator

msftrncs commented Nov 14, 2019

Originally posted by @wqsa in #1174 (comment)

2.0.0-beta5 still have this problem.

Environment

PSReadLine: 2.0.0-beta5
PowerShell: 7.0.0-preview.4
OS: Microsoft Windows 10.0.17763
Last 200 Keys

 DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow p c d n Spacebar s t a r t Spacebar - d a t a d i r Spacebar p e e r 1 Spacebar - c o n f i g Spacebar p c d n . c o n f Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 Ctrl+c UpArrow Enter
 UpArrow Enter
 Ctrl+c UpArrow Enter
 UpArrow DownArrow Ctrl+c UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow UpArrow DownArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow UpArrow DownArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 Ctrl+c UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Enter
 UpArrow Home d l v Spacebar e x e Spacebar Spacebar Backspace Backspace c Spacebar RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow - - Spacebar 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 9001.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.AcceptLineImpl(Boolean validate)
   at Microsoft.PowerShell.PSConsoleReadLine.AcceptLine(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)
@msftrncs
Copy link
Collaborator Author

It appears this happens when the last line of the buffer is completely full, but the cursor is not at the end, and then ENTER is used to accept the line.

msftrncs added a commit to msftrncs/PSReadLine that referenced this issue Nov 14, 2019
Instead of _console.SetCursorPosition(), use public API SetCursorPosition
so that existing end of buffer checks can be performed.

Fixes PowerShell#1181
msftrncs added a commit to msftrncs/PSReadLine that referenced this issue Nov 14, 2019
Instead of _console.SetCursorPosition(), use public API SetCursorPosition
so that existing end of buffer checks can be performed.

Fixes PowerShell#1181
@daxian-dbw
Copy link
Member

Thanks for hunting this down! I'm able to repro in beta5.

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

Successfully merging a pull request may close this issue.

2 participants