Exception when deleting invalid command retained from ValidateAndAcceptLine in Vi Mode
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the sequence in a profile-free pwsh session: Vi mode, bind Enter to ValidateAndAcceptLine, enter an invalid command, press Escape, then dd. Start from the ValidateAndAcceptLine and ViChordHandler paths shown in the exception, and verify that deleting the current input completes without the IndexOutOfRangeException.
Written by the indexing model from the issue text.
Description
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
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
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 341
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PowerShell/PSReadLine
-
Needs-Triage :mag:
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PowerShell/PSReadLine#5205 ·
-
Needs-Triage :mag:
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PowerShell/PSReadLine#5195 ·
-
Needs-Triage :mag:
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PowerShell/PSReadLine#5121 ·
-
Needs-Triage :mag:
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
PowerShell/PSReadLine#5045 ·
-
Area-CommandHelp Issue-Enhancement
Difficulty 1/5 Under an hour Newbie friendliness 68/100
PowerShell/PSReadLine#3470 · 3 reactions ·
All issues in PowerShell/PSReadLine
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
azurenoops/spin_agent#975 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·