Skip to content

Exception in a continuation prompt context with PredictionSource as HistoryAndPlugin and PredictionViewStyle as ListView #3347

@lewis-yeung

Description

@lewis-yeung

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

### Environment
PSReadLine: 2.2.5
PowerShell: 7.2.4
OS: Microsoft Windows 10.0.22000
BufferWidth: 110
BufferHeight: 45

Last 94 Keys:

 UpArrow DownArrow DownArrow " Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 Enter
 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 Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace

### 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.BackwardDeleteChar(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

screenshot-1

screenshot-2

Environment data

PS Version: 7.2.4
PS HostName: ConsoleHost
PSReadLine Version: 2.2.5
PSReadLine EditMode: Windows
OS: 10.0.22000.1 (WinBuild.160101.0800)
BufferWidth: 136
BufferHeight: 16

Steps to reproduce

  1. Run PowerShell without a profile (pwsh -noprofile).
  2. In a new prompt, run Set-PSReadlineOption -PredictionSource 'HistoryAndPlugin' -PredictionViewStyle 'ListView'. This is the paramount prerequisite.
  3. Enter a single or double quote character ('/"). This line is the "initial line".
  4. Press Enter repeatedly in a continuation prompt context until the "initial line" is out of the upper bound of the terminal screen buffer.
  5. Press Backspace repeatedly in a continuation prompt until the "initial line" is back.
  6. The above exception happens.

Something weird: The exception does not happen when there are five or more characters (including the unmatched quote) in the "initial line".

Expected behavior

No exception.

Actual behavior

The above exception happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIt either shouldn't be doing this or needs an investigation.Resolution-Fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions