Powershell: `ArgumentOutOfRangeException` if autocomplete wraps in VSCode

Created on 7 Jan 2020  路  5Comments  路  Source: PowerShell/PowerShell

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.

Issue-Question Resolution-External

Most helpful comment

All 5 comments

@ericwj I guess you should move the issue to https://github.com/PowerShell/PowerShellEditorServices

GitHub
A common platform for PowerShell development support in any editor or application! - PowerShell/PowerShellEditorServices

Duplicated with PS 5.1 in VSCode by just entering characters (no tab). Around the 160th character the error will be returned.

$PSVersionTable
Name Value
---- -----
PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

$host
Name : Visual Studio Code Host
Version : 2019.12.0
InstanceId : e60875d2-b4cd-438e-a528-d0d25e842ad9
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

@rjmholt Is the issue external?

This issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes.

Was this page helpful?
0 / 5 - 0 ratings