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

ArgumentOutOfRangeException when input exceeds console buffer #213

Closed
kimsey0 opened this issue Apr 4, 2022 · 3 comments · Fixed by #226
Closed

ArgumentOutOfRangeException when input exceeds console buffer #213

kimsey0 opened this issue Apr 4, 2022 · 3 comments · Fixed by #226
Assignees
Labels
bug Something isn't working

Comments

@kimsey0
Copy link
Contributor

kimsey0 commented Apr 4, 2022

When using Prompt.Input, if the user continues typing when the cursor reaches the last column of the last line in the buffer, Sharprompt crashes with:

Unhandled 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 System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Sharprompt.Drivers.DefaultConsoleDriver.SetCursorPosition(Int32 left, Int32 top)
   at Sharprompt.Internal.OffscreenBuffer.RenderToConsole()
   at Sharprompt.Internal.RenderScope.Dispose()
   at Sharprompt.Forms.FormRenderer.Render(Action`1 template)
   at Sharprompt.Forms.FormBase`1.Start()
   at Sharprompt.Prompt.Input[T](InputOptions`1 options)
   at Sharprompt.Prompt.Input[T](Action`1 configure)
   at Sharprompt.Prompt.Input[T](String message, Object defaultValue, String placeholder, IList`1 validators)
   at Program.<Main>$(String[] args) in C:\Projects\CommandLineCrash\Program.cs:line 6

A minimal program reproducing this problem:

for (var i = 0; i < Console.BufferHeight; i++)
{
    Console.WriteLine();
}

Sharprompt.Prompt.Input<string>("Type any character".PadRight(Console.BufferWidth - 5));

I can reproduce the problem in the Windows Console and in Windows Terminal running either cmd.exe or PowerShell, but not in any of them when running bash through WSL 2.

@kimsey0
Copy link
Contributor Author

kimsey0 commented Apr 4, 2022

(If you paste a text snippet that is long enough to exceed the available space on the last line, this does not trigger the crash. Instead, it properly continues the prompt input on the next line, but still crashes if you then continue writing and reach the end of that new line.)

@shibayan shibayan self-assigned this Apr 4, 2022
@shibayan shibayan added the bug Something isn't working label Apr 4, 2022
@shibayan
Copy link
Owner

shibayan commented Apr 4, 2022

It is a renderer issue and will take time but will be fundamentally fixed.

@shibayan shibayan added this to the v3.0.0 Release milestone Apr 4, 2022
@kimsey0
Copy link
Contributor Author

kimsey0 commented Apr 4, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants