Skip to content

Tab autocomplete in a Cmdlet param context #2928

@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-beta3
PowerShell: 7.1.5
OS: Microsoft Windows 10.0.22483
BufferWidth: 133
BufferHeight: 30

Last 200 Keys

 Spacebar Enter
 $ i Tab n s Enter
 Spacebar - r e p l Tab Spacebar " " LeftArrow C : \ \ U s e r s \ \ m a v a d Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow RightArrow RightArrow \ \ Ctrl+RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow \ \ Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow , " " LeftArrow $ e n v : H O M E Tab RightArrow Enter
 Ctrl+LeftArrow Ctrl+LeftArrow ` Ctrl+RightArrow Ctrl+LeftArrow Ctrl+RightArrow Ctrl+RightArrow LeftArrow Enter
 UpArrow Spacebar | Spacebar s e t - c l i Tab Enter
 UpArrow UpArrow UpArrow ) Home Ctrl+RightArrow Ctrl+RightArrow Ctrl+LeftArrow ( End Spacebar - r e p Tab Spacebar Spacebar " C : \ \ \ \ U s e r s \ \ \ \ m a v a d " , " ` $ e n v : H O M E P A T H " Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Shift+Ctrl+RightArrow Shift+Ctrl+RightArrow Shift+Ctrl+RightArrow Shift+LeftArrow Shift+LeftArrow Shift+LeftArrow Delete $ e n v : H O M E Tab RightArrow Enter
 Ctrl+LeftArrow Ctrl+LeftArrow Enter
 UpArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Backspace Ctrl+RightArrow Ctrl+RightArrow LeftArrow LeftArrow LeftArrow Delete Spacebar LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow LeftArrow Spacebar [ ] LeftArrow r e g 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

I attempted to tab here.
Tab attempted at this position of the line

Environment data

PS Version: 7.1.5
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.2.0-beta3
PSReadLine EditMode: Windows
OS: 10.0.22483.1000 (WinBuild.160101.0800)
BufferWidth: 133
BufferHeight: 30

Steps to reproduce

To get the error in the first place, I recalled the following into Pwsh without pressing enter (by pressing up arrow to recall last command):

$instMods = (Get-InstalledModule  | ConvertTo-Html | pandoc.exe --from=html-auto_identifiers-native_spans-native_divs --to=gfm-gfm_auto_identifiers) -replace  [reg] $env:HOMEPATH ,"`$env:HOMEPATH"

Nav back to the position at reg inside [reg] $env and press tab.

Expected behavior

Autocomplete regex assembly inside square brackets.

Actual behavior

System.ArgumentOutOfRangeException

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