PowerShell autocomplete crashes if larger than current screen #9941

Open
opened 2026-01-31 02:08:02 +00:00 by claunia · 0 comments
Owner

Originally created by @cjoprey on GitHub (Jul 31, 2020).

Environment

Windows build number: Microsoft Windows NT 10.0.18363.0
Windows Terminal version (if applicable): 1.2.2022.0
PowerShell version: 5.1.18362.752

Steps to reproduce

  • Open a PowerShell window in Windows Terminal
  • Run the following: cd \Windows
  • Enter dir<space>
  • Hit ctrl + space to trigger the autocomplete. It should say something like "Display all 136 possibilities? (y or n) _"
  • Hit "y"

Expected behavior

In a normal PowerShell window, it now lists all entries. Below is a snip from PowerShell.exe:

C:\Windows> dir
addins
appcompat
apppatch
< ...snipped all the other entries... >
WinSxS
wlansvc
WMSysPr9.prx
write.exe
C:\Windows> dir    

Actual behavior

In Windows terminal, with the same console size (checked with $Host.UI.RawUI.WindowSize), it causes PowerShell to crash with an out of bounds error, and I believe it it because there is no forward buffer like there is in PowerShell.exe:

Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 200 Keys:
 g i t Space b r a n c h Space Tab Ctrl+Space Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Space Backspace Space b r n a h c Space Backspace Backspace Backspace Backspace Backspace a n c h Space Ctrl+Space Escape Escape Escape c l s Enter
 c d Space . . Enter
 c l s Enter
 $ H o s t . U I . R a w U I . W i n d o w S i z e Enter
 c d Space \ w i n d w Tab Backspace Tab Enter
 c l s Enter
 UpArrow UpArrow UpArrow Enter
 d i r Space Ctrl+Space y Escape c l s Enter
 UpArrow UpArrow Enter
 [ E n v i r o n m e n t ] : : O S V e r s i o n Enter
 d i r Space Ctrl+Space Escape Backspace Backspace Backspace Backspace c l s Enter
 UpArrow UpArrow UpArrow UpArrow DownArrow Enter
 $ p s v e r Tab Enter
 d i r Space Ctrl+Space y

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 name: top
Actual value was -99.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.Menu.EnsureMenuAndInputIsVisible(IConsole console, Int32 tooltipLineCount)
   at Microsoft.PowerShell.PSConsoleReadLine.Menu.DrawMenu(Menu previousMenu)
   at Microsoft.PowerShell.PSConsoleReadLine.PossibleCompletionsImpl(CommandCompletion completions, Boolean menuSelect)
   at Microsoft.PowerShell.PSConsoleReadLine.CompleteImpl(Boolean menuSelect)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------
C:\Windows> dir     
Originally created by @cjoprey on GitHub (Jul 31, 2020). # Environment ```none Windows build number: Microsoft Windows NT 10.0.18363.0 Windows Terminal version (if applicable): 1.2.2022.0 PowerShell version: 5.1.18362.752 ``` # Steps to reproduce - Open a PowerShell window in Windows Terminal - Run the following: `cd \Windows` - Enter `dir<space>` - Hit ctrl + space to trigger the autocomplete. It should say something like "Display all 136 possibilities? (y or n) _" - Hit "y" # Expected behavior In a normal PowerShell window, it now lists all entries. Below is a snip from PowerShell.exe: ``` C:\Windows> dir addins appcompat apppatch < ...snipped all the other entries... > WinSxS wlansvc WMSysPr9.prx write.exe C:\Windows> dir ``` # Actual behavior In Windows terminal, with the same console size (checked with $Host.UI.RawUI.WindowSize), it causes PowerShell to crash with an out of bounds error, and I believe it it because there is no forward buffer like there is in PowerShell.exe: ``` Oops, something went wrong. Please report this bug with the details below. Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new ----------------------------------------------------------------------- Last 200 Keys: g i t Space b r a n c h Space Tab Ctrl+Space Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Space Backspace Space b r n a h c Space Backspace Backspace Backspace Backspace Backspace a n c h Space Ctrl+Space Escape Escape Escape c l s Enter c d Space . . Enter c l s Enter $ H o s t . U I . R a w U I . W i n d o w S i z e Enter c d Space \ w i n d w Tab Backspace Tab Enter c l s Enter UpArrow UpArrow UpArrow Enter d i r Space Ctrl+Space y Escape c l s Enter UpArrow UpArrow Enter [ E n v i r o n m e n t ] : : O S V e r s i o n Enter d i r Space Ctrl+Space Escape Backspace Backspace Backspace Backspace c l s Enter UpArrow UpArrow UpArrow UpArrow DownArrow Enter $ p s v e r Tab Enter d i r Space Ctrl+Space y 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 name: top Actual value was -99. at System.Console.SetCursorPosition(Int32 left, Int32 top) at Microsoft.PowerShell.PSConsoleReadLine.Menu.EnsureMenuAndInputIsVisible(IConsole console, Int32 tooltipLineCount) at Microsoft.PowerShell.PSConsoleReadLine.Menu.DrawMenu(Menu previousMenu) at Microsoft.PowerShell.PSConsoleReadLine.PossibleCompletionsImpl(CommandCompletion completions, Boolean menuSelect) at Microsoft.PowerShell.PSConsoleReadLine.CompleteImpl(Boolean menuSelect) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.InputLoop() at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics) ----------------------------------------------------------------------- C:\Windows> dir ```
claunia added the Resolution-ExternalNeeds-Tag-Fix labels 2026-01-31 02:08:02 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9941