Skip to content

ArgumentOutOfRangeException when pressing UpArrow in empty or resized console window in VSC #4773

@qrexpy

Description

@qrexpy

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less Parameter name: top
Actual value was -1.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defausHistory(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.4291
PS HostName: ConsoleHost
PSReadLine Version: 2.0.0-beta2
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 93
BufferHeight: 15

Steps to reproduce

  1. Open Visual Studio Code.
  2. Open a new integrated terminal (e.g., PowerShell).
  3. Without typing anything, press the UpArrow key to recall the previous command.
  4. Observe that the previous command appears, but an exception is thrown in the background.

Expected behavior

Pressing the UpArrow key in a new terminal should recall the previous command from history without throwing any exceptions.

Actual behavior

The previous command is successfully recalled and displayed, but an unhandled System.ArgumentOutOfRangeException is thrown:

System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less Parameter name: top
Actual value was -1.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions