Skip to content

ArgumentOutOfRangeException if autocomplete wraps in VSCode #11511

@ericwj

Description

@ericwj

Steps to reproduce

In Visual Studio Code, do dir near the right end of the terminal window and type C:\win, hitting tab to autocomplete into any directory until the exception occurs. The same happens with other commands when it wraps pressing Tab to autocomplete the parameter name or the value.

In Windows Terminal, this works - no exception occurs. Although the output may be garbled while editing the command, depending on how big the window is.

"  <as many spaces as necessary to get near the right margin> "; dir "C:\Windows\assembly\NativeImages_v4.0.30319_32\Sys"

Hit Tab.

Expected behavior

The path wraps and the autocomplete leaves the cursor at the end of the autocompleted name.

Actual behavior

An error occurred while reading input:

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 20.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.EditorServices.Console.ConsoleReadLine.InsertInput(StringBuilder inputLine, Int32 promptStartCol, Int32 promptStartRow, String insertedInput, Int32 cursorIndex, Int32 insertIndex, Int32 replaceLength, Int32 finalCursorIndex)
   at Microsoft.PowerShell.EditorServices.Console.ConsoleReadLine.ReadLine(Boolean isCommandLine, CancellationToken cancellationToken)
   at Microsoft.PowerShell.EditorServices.EditorServicesPSHostUserInterface.StartReplLoop(CancellationToken cancellationToken)

The cursor will be after a new prompt and the command that was being constructed is lost completely.

Environment data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0-rc.1
PSEdition                      Core
GitCommitId                    7.0.0-rc.1
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

$Host

Name             : Visual Studio Code Host
Version          : 2019.12.0
InstanceId       : 0f133d7e-f721-4390-9231-955d3fefc0a2
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.EditorServices.EditorServicesPSHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Help | About
image

Could say this is a VSCode issue but the stacktrace in fact doesn't have anyhting VSCode related in it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-ExternalThe issue is caused by external component(s).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions