Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception when deleting invalid command retained from ValidateAndAcceptLine in Vi Mode #3919

Open
3 tasks done
HenriquedoVal opened this issue Jan 14, 2024 · 0 comments
Open
3 tasks done
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-More Investigation Initial investigation is done, but need to follow up.

Comments

@HenriquedoVal
Copy link

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.3.4
PowerShell: 7.4.0
OS: Microsoft Windows 10.0.22621
BufferWidth: 169
BufferHeight: 41

Last 114 Keys:

 S e t - P S R e a d L i n e O p t i o n Spacebar - E d i t M o d e Spacebar V i Enter S e t - P S R e a d L i n e K e y H a n d l e r Spacebar - K e y Spacebar E n t e r Spacebar - F u n c t i o n Spacebar V a l i d a t e A n d A c c e p t L i n e Enter n o t v a l i d Enter Escape d d

### 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.RenderWithPredictionQueryPaused()
   at Microsoft.PowerShell.PSConsoleReadLine.ClearStatusMessage(Boolean render)
   at Microsoft.PowerShell.PSConsoleReadLine.SaveEditItem(EditItem editItem)
   at Microsoft.PowerShell.PSConsoleReadLine.DeleteLineImpl(Int32 lineIndex, Int32 lineCount)
   at Microsoft.PowerShell.PSConsoleReadLine.DeleteLine(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(PSKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ViChordHandler(Dictionary`2 secondKeyDispatchTable, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ViChord(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

Environment data

PS Version: 7.4.0
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.3.4
PSReadLine EditMode: Vi
OS: 10.0.22621.2428 (WinBuild.160101.0800)
BufferWidth: 169
BufferHeight: 41

Steps to reproduce

Start pwsh without profile, set edit mode to Vi, set Enter key handler to ValidateAndAcceptLine, enter a not valid command, press Escape to exit insert mode, enter dd

Expected behavior

The current input is deleted

Actual behavior

The above exception happens

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Jan 14, 2024
@daxian-dbw daxian-dbw added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-More Investigation Initial investigation is done, but need to follow up. and removed Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. labels Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-More Investigation Initial investigation is done, but need to follow up.
Projects
None yet
Development

No branches or pull requests

2 participants