Skip to content

Unexpected exception while using PowerShell in Windows Terminal #5224

Open

Description

@kurowyn

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

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.4.5
PowerShell: 7.6.6
OS: Microsoft Windows 10.0.26200
BufferWidth: 103
BufferHeight: 30

Last 200 Keys:

 Escape F [ i ( Escape A ) + " Escape F [ i ( Escape f } f + a ) Enter Escape k A Shift+Spacebar & & Shift+Spacebar e c h o Shift+Spacebar $ M a t Tab Enter Escape k f " i Spacebar 8 3 2 8 Spacebar 8 2 8 1 2 Enter Ctrl+l Escape k Enter Escape k f " ; i Escape l a ^ Escape f " i $ Enter Ctrl+l Escape k Enter Escape k k Enter Escape k Enter Ctrl+l Escape k Enter Escape k f " i Spacebar Enter Escape k Enter [ r e g e Tab ] : : M a t Tab Backspace Backspace h Tab " 1 2 3 4 Spacebar 1 2 3 4 Spacebar 1 2 3 4 " , Spacebar " Backspace Escape p Escape l " ( ( [ 0 - 9 ] + ) \ s ) + " Ctrl+c Ctrl+l Ctrl+v Ctrl+c Escape k k k j Ctrl+c [ r e g Tab r e r e r e r e r e r e r e r e r e r e r e r e r e

### Exception

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Text.StringBuilder.get_Chars(Int32 index)
   at Microsoft.PowerShell.PSConsoleReadLine.ReplaceCharInPlace(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics, CancellationToken cancellationToken, Nullable`1 lastRunStatus)

Screenshot

Image

Username hidden for anonymity.

Environment data

PS Version: 7.6.6
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.4.5
PSReadLine EditMode: Vi
OS: 10.0.26100.1 (WinBuild.160101.0800)
BufferWidth: 103
BufferHeight: 30

Steps to reproduce

I'm not exactly sure what caused this to happen. I was just playing around with PowerShell's regex matching, and then all of a sudden, this happened. Of course, I was using the Vi keybindings.

Expected behavior

No exceptions.

Actual behavior

An exception occurred all of a sudden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-Triage 🔍It's a new issue that core contributor team needs to triage.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions