Skip to content

[vi-mode] GotoFirstNonBlankOfLine crashes PSRL when buffer is empty #2050

Closed

Description

Environment

PS version: 7.2.0-daily.20201215
PSReadline version: 2.1.0
os: 10.0.18362.1130 (WinBuild.160101.0800)
PS file version: 7.2.0.0
HostName: ConsoleHost (Windows Terminal)
BufferWidth: 120
BufferHeight: 30

Exception report

Last 24 Keys

 S e t - P S R e a d L i n e O p t i o n RightArrow Enter Escape _

Exception

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Text.StringBuilder.get_Chars(Int32 index)
   at Microsoft.PowerShell.PSConsoleReadLine.IsVisibleBlank(Int32 newCurrent)
   at Microsoft.PowerShell.PSConsoleReadLine.GetFirstNonBlankOfLogicalLinePos(Int32 current)
   at Microsoft.PowerShell.PSConsoleReadLine.GotoFirstNonBlankOfLine(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)

Steps to reproduce

Run PSRL:

Set-PSReadLineOption -EditMode Vi

Then type the following sequence: Esc, _

Expected behavior

Nothing should happen. Possibly, key may ding.

Actual behavior

PSRL crashes.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions