PowerShell / PSReadLine

A bash inspired readline implementation for PowerShell
BSD 2-Clause "Simplified" License
3.77k stars 298 forks source link

PSreadline expcetion report #4230

Closed CN-CODEGOD closed 1 month ago

CN-CODEGOD commented 1 month ago

Prerequisites

Exception report

PS>Oops, something went wrong.
> Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
> Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.yaml
> Thank you!
>
> ### Environment
> PSReadLine: 2.3.5+2cc85806c561a9395751a96a818e8ff1592d19f7
> PowerShell: 7.4.5
> OS: Microsoft Windows 10.0.19045
> BufferWidth: 120
> BufferHeight: 9001
>
> Last 200 Keys:
>
>  RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow 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 Backspace Backspace Backspace Backspace Backspace Backspace End Backspace Backspace Backspace s LeftArrow End Spacebar " LeftWindows Ctrl+v " Enter
>  UpArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow " RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow RightArrow LeftArrow LeftArrow LeftArrow LeftArrow " Enter
>  s t a r t Spacebar RightArrow Enter
>  c l s Enter
>  d Backspace Backspace d
>
> ### Exception
>
> System.IO.IOException: 参数错误。
>    at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
>    at Microsoft.PowerShell.PSConsoleReadLine.CalculateWhereAndWhatToRender(Boolean cursorMovedToInitialPos, RenderData renderData, LineInfoForRendering& lineInfoForRendering)
>    at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
>    at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
>    at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(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

image

Environment data

PS Version: 7.4.5
PS HostName: ConsoleHost
PSReadLine Version: 2.3.5
PSReadLine EditMode: Windows
OS: 10.0.19041.4522 (WinBuild.160101.0800)
BufferWidth: 317
BufferHeight: 9001

Steps to reproduce

typing with chinese input method

Expected behavior

null

Actual behavior

null

daxian-dbw commented 1 month ago

@CN-CODEGOD Can you please provide the repro steps? Without them, there isn't much that we can do ... Thanks!

CN-CODEGOD commented 1 month ago

@CN-CODEGOD Can you please provide the repro steps? Without them, there isn't much that we can do ... Thanks!

do you know what happen .i was accidently get the bug from psreadline ,sorry i can't provide a repro step,

daxian-dbw commented 1 month ago

Thanks @CN-CODEGOD for opening the issue. However, I have to close it because there is no sufficient information for the investigation.

Poltergeisen commented 1 month ago

I'm also seeing the same thing. @daxian-dbw, I just installed the gh CLI today with winget

winget install --id GitHub.cli

Then with this code in my $profile:


kubectl completion powershell | Out-String | Invoke-Expression
flux completion powershell | Out-String | Invoke-Expression
gh completion -s powershell | Out-String | Invoke-Expression

set-alias -name tf -value terraform
set-alias -name k -value kubectl

Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

when I type gh copilot and hit tab it throws this exception.

Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 18 Keys:
 g h Space c Backspace Tab Escape c o Tab p o i Backspace Backspace i Tab 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 name: top
Actual value was -18.
   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)
-----------------------------------------------------------------------

@daxian-dbw

Poltergeisen commented 1 month ago

For anyone else viewing this, my problem was with an outdated ps readline. The github actions bot here solved my problem:

https://github.com/PowerShell/PSReadLine/issues/4232