Skip to content

PSReadline throws exception when typing commands #4763

@jrjespersen

Description

@jrjespersen

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.3.6+d2e770f93b7a53d8660a6402eb29d1ae1c35e767
PowerShell: 7.5.1
OS: Amazon Linux 2023.7.20250428
BufferWidth: 0
BufferHeight: 0

Last 1 Keys:

 g

### Exception

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Text.StringBuilder.get_Chars(Int32 index)
   at Microsoft.PowerShell.PSConsoleReadLine.ConvertOffsetToPoint(Int32 offset)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Render()
   at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   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

####NOTE: in order to run the commands, I had to first run Remove-Module PSReadLine
PS Version: 7.5.1
PS HostName: ConsoleHost
PSReadLine Version:
PSReadLine EditMode: Emacs
OS: Linux ip-10-120-151-206.intranet.local 6.1.132-147.221.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr  8 13:14:54 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
BufferWidth: 0
BufferHeight: 0

Steps to reproduce

This is an Amazon Linux 2023 image running in AWS and using Session Manager (through AWS Systems Manager agent) to establish a console session in a browser tab.

  • Connect to instance via Session Manager
  • run pwsh
  • type any character

Expected behavior

command suggestions based on history (or no error if no suggestions available)

Actual behavior

Exception. Additionally, the exception happens every other command (Command 1 attempt fails, command 2 successful, Command 3 attempt fails, etc). Copy/paste of commands makes no difference. Also, no command history is available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions