Skip to content

Resizing windows before Escape results in ArgumentOutOfRangeException #1884

Closed

Description

Environment

PSReadLine: 2.0.2
PowerShell: 7.0.3
OS: Microsoft Windows 10.0.19041
Last 200 Keys

 LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow RightArrow RightArrow RightArrow Backspace Backspace Backspace Backspace Backspace Backspace Backspace g e t Enter
 UpArrow Escape

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 29.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.RevertLine(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)
PS version: 7.0.3
PSReadline version: 2.0.2
os: 10.0.19041.1 (WinBuild.160101.0800)
PS file version: 7.0.3.0
HostName: ConsoleHost (Windows Terminal)
BufferWidth: 131
BufferHeight: 29

Exception report

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 29.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.RevertLine(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)

Steps to reproduce

I was using Powershell to issue a few HTTPie commands, which involved recalling the last command and using left and/or ctrl+left to go back over the last command to slightly edit it. I resized the window (for the purposes of a screen shot) and this issue occured.

[Edited] This issue happens only when you resize the window after UpArrow and before Escape.

Expected behavior

No error message

Actual behavior

The error

Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.md

Along with the details above

Activity

  1. ghost added
    Needs-Triage 🔍It's a new issue that core contributor team needs to triage.
    on Oct 15, 2020
  2. daxian-dbw commented on Oct 16, 2020

    @daxian-dbw
    Member

    Mark Murphy (@markSmurphy) Thanks for reporting this issue. We have been receiving some reports about this exception stack on PSReadLine 2.0.x versions but couldn't get a repro to investigate the problem.

    I was using Powershell to issue a few HTTPie commands, which involved recalling the last command and using left and/or ctrl+left to go back over the last command to slightly edit it. I resized the window (for the purposes of a screen shot) and this issue occured.

    Looking at the the Last 200 Keys, when did you resize the window? For example, did you resize the window after the UpArrow and before Escape?
    How did you resize the window? Shrink/increase both the width and height? Shrink/increase only the width or height?

    Information about those questions would be very helpful to our investigation. Thank you in advance!

  3. daxian-dbw commented on Oct 16, 2020

    @daxian-dbw
    Member

    Also, if possible, can you please share a screenshot of the terminal content that is shown right above the exception message?

  4. markSmurphy commented on Oct 16, 2020

    @markSmurphy
    Author

    Here's the screen shot you asked for.
    In case it's relevant, the pwsh.exe process has been active for 17 days, so there's quite a build up of command history.

    I can't reproduce this at will.

    You can make out (in the screen shot below) the HTTPie command at the top of the screen "http get https://...." - the previous command was "http options https://..." and you can see in the "Last 200 keys" me navigating back over the line, deleting the seven characters in " O P T I O N S" and replacing it with "get" before executing it.
    image

  5. daxian-dbw commented on Oct 16, 2020

    @daxian-dbw
    Member

    Mark Murphy (@markSmurphy) Appreciate your reply and the screenshot. I think I can reproduce the exception now. Will investigate further. Thanks.

  6. ckrueger1979 commented on Oct 28, 2020

    @ckrueger1979

    Haveing the same problem. For me it happens frequently after pasting text from Outlookt to Powershell

  7. daxian-dbw commented on Oct 30, 2020

    @daxian-dbw
    Member

    @ckruegerkpmg I doubt you are facing the same issue. This issue happens only when you resize the window after UpArrow and before Escape.

    If you see the same exception stack, it's likely already fixed (see #1306). Please upgrade to the 2.1.0-rc1 version of PSReadLine from PowerShellGallery. See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.

  8. taketakeyyy commented on Nov 8, 2020

    @taketakeyyy
  9. daxian-dbw commented on Nov 9, 2020

    @daxian-dbw
    Member

    takey (@taketakeyyy) You are using a very old version of PSReadLine, maybe 2.0.0-beta1 or prior. Please upgrade to the 2.1.0 version of PSReadLine from PowerShellGallery. See the upgrading section for instructions. Please file a new issue if you run into the same issue with the latest version.

  10. maettu-this commented on Feb 4, 2021

    @maettu-this
  11. maettu-this commented on Feb 4, 2021

    @maettu-this
  12. changed the title [-]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')[/-] [+]Resizing windows before `Escape` results in ArgumentOutOfRangeException[/+] on Feb 24, 2021
  13. ghost added
    In-PRA PR is opened targeting the issue
    on Nov 30, 2021
  14. ghost removed
    In-PRA PR is opened targeting the issue
    on Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIt either shouldn't be doing this or needs an investigation.Resolution-Fixed

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions