Prerequisites
Exception report
### Environment
PSReadLine: 2.4.5
PowerShell: 7.6.0-preview.5
OS: Microsoft Windows 10.0.26100
BufferWidth: 120
BufferHeight: 9001
Last 200 Keys:
d l i n e o p Tab Tab Spacebar Spacebar Backspace - Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Tab Shift+Tab Spacebar Tab Tab Tab Enter
d f d f Backspace Backspace Backspace Backspace s e t - p s r e a d l i n e k e y h a n d l e r Spacebar c Backspace - c h o r t Tab Backspace d Tab 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 n o t e p a d Spacebar . \ p r o f i l e . p s q Backspace 1 Enter
. Spacebar p r o Tab Enter
t h i s Spacebar i d Spacebar a Spacebar d Backspace Backspace Backspace Backspace Backspace s Spacebar a Spacebar d e b a Backspace u g Spacebar t e s t LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow Ctrl+a LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow Ctrl+b Ctrl+b
### Exception
System.ArgumentOutOfRangeException: Index and length must refer to a location within the string. (Parameter 'length')
at System.Text.StringBuilder.ToString(Int32 startIndex, Int32 length)
at Microsoft.PowerShell.PSConsoleReadLine.Kill(Int32 start, Int32 length, Boolean prepend)
at Microsoft.PowerShell.PSConsoleReadLine.KillRegion(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.6.0-preview.5
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.4.5
PSReadLine EditMode: Windows
OS: 10.0.26100.1 (WinBuild.160101.0800)
BufferWidth: 120
BufferHeight: 9001
Steps to reproduce
- Bind both the
KillRegion and SetMark functions to a chord each (this is what profile.ps1 does in the example above)
- Set a mark with `SetMark anywhere on the line, except on the first column
- Move the cursor before the mark
- Kill the region of text between the cursor and the mark with
KillRegion
- Try to kill the region again
Expected behavior
Since the region is empty and thus cannot be killed, the function should return a ding.
Actual behavior
An unhandled exception is raised.
Prerequisites
Exception report
Screenshot
Environment data
Steps to reproduce
KillRegionandSetMarkfunctions to a chord each (this is whatprofile.ps1does in the example above)KillRegionExpected behavior
Since the region is empty and thus cannot be killed, the function should return a ding.
Actual behavior
An unhandled exception is raised.