Skip to content

Exception on autocomplete attempt for recalled Add-Type cmdlet #3073

@mavaddat

Description

@mavaddat

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

### Environment
PSReadLine: 2.2.0-beta4
PowerShell: 7.2.0-rc.1
OS: Microsoft Windows 10.0.22504
BufferWidth: 120
BufferHeight: 30

Last 200 Keys:

 n t . L e n g t h ) Enter
 $ s z E x t r a c t o r Spacebar = Spacebar N e w - O b j e c t Spacebar - T y p e N a m e Spacebar S e v e n Z i p E x t r a c t o r Spacebar - A r g u m e n t L i s t Spacebar @ ( $ s e v e n Z i p S t r e a m , [ S e v e n Z i p . I n A r c h i v e F o r m a t ] : : X Z ) Enter
 UpArrow Ctrl+a RightArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow s e v e Tab RightArrow LeftArrow RightArrow RightArrow Enter
 ] : : Shift+Tab Tab x RightArrow Enter
 Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+LeftArrow Ctrl+c RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow ) Enter
 UpArrow Ctrl+LeftArrow Ctrl+a Delete $ _ Enter
 UpArrow DownArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow LeftArrow - v e r Tab Enter
 UpArrow LeftArrow Spacebar - w Tab

### 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 30.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.Menu.DrawMenu(Menu previousMenu, Boolean menuSelect)
   at Microsoft.PowerShell.PSConsoleReadLine.MenuCompleteImpl(Menu menu, CommandCompletion completions)
   at Microsoft.PowerShell.PSConsoleReadLine.PossibleCompletionsImpl(CommandCompletion completions, Boolean menuSelect)
   at Microsoft.PowerShell.PSConsoleReadLine.CompleteImpl(Boolean menuSelect)
   at Microsoft.PowerShell.PSConsoleReadLine.MenuComplete(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, Nullable`1 lastRunStatus)

Screenshot

Just before the exception:

screenshot of powershell in windows terminal right before the exception

Just after the exception:

screenshot of powershell in windows terminal just after the exception

Environment data

Field Value
PS Version 7.2.0-rc.1
PS HostName ConsoleHost (Windows Terminal)
PSReadLine Version 2.2.0-beta4
PSReadLine EditMode Windows
OS 10.0.22504.1000 (WinBuild.160101.0800)
BufferWidth 120
BufferHeight 30

Steps to reproduce

Up-arrow to recall this command from history:

(Get-Item (Join-Path (Split-Path (Get-Package SevenZipExtractor).Source) lib/netstandard*) |
  Sort-Object { [version] ($_.Name -replace '^netstandard') })[-1] |
    Get-ChildItem -Filter *.dll -Recurse |
      ForEach-Object { Write-Host "Adding ``$($_.Name)``"; Add-Type -LiteralPath $_.FullName -Verbose}

Left-arrow to place cursor just after - and before Verbose in the -Verbose of the (lower) innermost command then tab to autocomplete.

Expected behavior

Show that there are switches starting with w for the Add-Type cmdlet using the autocomplete suggestions.

Actual behavior

Exception on tab-autocomplete attempt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-DuplicateThere's another issue on the tracker that's pretty much the same thing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions