IndexOutOfRangeException following an attempt to type after running `dotnet build`

Open
#4,946 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp, powershell
Domain
cli

Research direction

Start at Microsoft.PowerShell.PSConsoleReadLine.ReplaceCharInPlace in the stack trace and inspect how the input buffer is updated after the reported dotnet build command. Reproduce the failure if possible and verify that typing after the command no longer raises IndexOutOfRangeException; the report provides no specific reproduction steps or test file.

Written by the indexing model from the issue text.

Description

Needs-Triage :mag:
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.3
OS: Microsoft Windows 10.0.26100
BufferWidth: 133
BufferHeight: 71

Last 200 Keys:

 F V . D o c s . C o r e Spacebar t o Spacebar . N E T Spacebar 7 Backspace 8 Escape 0 C g i t Spacebar l o g Enter g i t Spacebar c o Backspace Backspace s t a t u s Enter g i t Spacebar c o m m i t Spacebar - m Spacebar " U p g r a d e Spacebar F C Backspace V . D o c s . C o r e Spacebar t o Spacebar . N E T Spacebar 8 " Enter g i t Spacebar s t a t u s Enter Enter g i t Spacebar s t a t u s Enter d o t n e t Spacebar b u i l d Spacebar F i l e v i n e . S e r v i c e s / F i l e v i n e . / Backspace S e r v i c e s . c s p r o j Spacebar - c Spacebar R e l e a s e Enter UpArrow Enter UpArrow Enter Escape . \ r u

### 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

The screenshot may contain sensitive information, but I can tell you that the last output was from a dotnet build command.

Environment data
PS Version: 7.5.3
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.3.6
PSReadLine EditMode: Vi
OS: 10.0.26100.1 (WinBuild.160101.0800)
BufferWidth: 133
BufferHeight: 71
Steps to reproduce

I experienced a delay when attempting to type at the prompt, then I got the exception text. I do not have specific steps to reproduce. This is the first time I have encountered this message.

Expected behavior

Not having an exception.

Actual behavior

There was a delay when I attempted to type, then I got the exception test pasted earlier.

Dominant language
C#
Stars
4.4k
Forks
341
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/PSReadLine

All issues in PowerShell/PSReadLine

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.