Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
mavaddat opened this issue Nov 29, 2021 · 2 comments
Closed
3 tasks done

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

mavaddat opened this issue Nov 29, 2021 · 2 comments
Labels
Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@mavaddat
Copy link

mavaddat commented Nov 29, 2021

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.

@ghost ghost added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Nov 29, 2021
@mavaddat
Copy link
Author

mavaddat commented Nov 29, 2021

Ok, as soon as I wrote that I was not able to reproduce the error, I reproduced it.

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:

 Shift+LeftArrow Shift+LeftArrow S e v e Tab RightArrow Enter
 Enter
 UpArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Ctrl+RightArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow Ctrl+LeftArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+Ctrl+LeftArrow Shift+LeftArrow Shift+Ctrl+LeftArrow Shift+LeftArrow Delete Enter
 UpArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow Backspace . Tab Tab Tab Tab Tab Shift+Tab Shift+Tab Shift+Tab Shift+Tab Enter
 Enter
 UpArrow Spacebar Backspace . Tab Backspace Tab Spacebar = - Backspace Backspace - 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 E x t r a c t o r . S e v e n Z i p F o r m a t ] : : X Z ) Enter
 UpArrow Ctrl+a Ctrl+x UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow LeftArrow Shift+Ctrl+LeftArrow Shift+LeftArrow Shift+LeftArrow Delete ) Ctrl+LeftArrow Ctrl+LeftArrow ( Ctrl+RightArrow Ctrl+RightArrow Ctrl+RightArrow LeftArrow Spacebar - f Tab Tab Backspace 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.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

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 - of the (lower) innermost command and press 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.

@daxian-dbw
Copy link
Member

This is a duplicate of #2928, which was fixed by #2949. See the GIF below.
@mavaddat Can you maybe use the private build from https://ci.appveyor.com/project/PowerShell/PSReadLine/branch/master/artifacts? It contains the fix to the menu completion, which you will find useful.

Animation

@ghost ghost removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Nov 29, 2021
@daxian-dbw daxian-dbw added the Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. label Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

2 participants