Repository navigation
Right-click earlier text in console readout, then hit escape causes exception #1597
Copy link
Copy link
Closed
Labels
Resolution-DuplicateThere's another issue on the tracker that's pretty much the same thing.There's another issue on the tracker that's pretty much the same thing.
Description
Environment
| Attribute | Value |
|---|---|
| PS version | 7.1.0-preview.3 |
| PSReadline version | 2.1.0-beta1 |
| os | 10.0.19640.1 (WinBuild.160101.0800) |
| PS file version | 7.1.0.0 |
| HostName | ConsoleHost |
| BufferWidth: | 104 |
| BufferHeight | 1000 |
e n v : P R O Tab Tab Tab Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace Backspace g Tab Tab Tab \ Delete Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Enter
g e t - p r o Tab Spacebar - Tab Tab 2 3 2 2 0 LeftArrow LeftArrow LeftArrow LeftArrow LeftArrow Spacebar Enter
UpArrow Ctrl+Backspace 2 0 5 4 8 Enter
UpArrow UpArrow UpArrow Ctrl+a Ctrl+x UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow Enter
UpArrow Home Ctrl+RightArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow UpArrow DownArrow DownArrow Enter
UpArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow LeftArrow LeftArrow Ctrl+Delete Ctrl+RightArrow LeftArrow LeftArrow Ctrl+Delete Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+z Ctrl+z Ctrl+LeftArrow Ctrl+LeftArrow LeftArrow LeftArrow LeftArrow RightArrow Shift+Ctrl+RightArrow Shift+Ctrl+RightArrow Shift+LeftArrow Shift+LeftArrow Shift+LeftArrow Shift+LeftArrow Shift+LeftArrow Shift+LeftArrow Shift+RightArrow Ctrl+x Ctrl+RightArrow LeftArrow LeftArrow Shift+Ctrl+RightArrow Shift+Ctrl+RightArrow Shift+LeftArrow Shift+LeftArrow Shift+LeftArrow Shift+LeftArrow Shift+LeftArrow Shift+LeftArrow - - h e l p Ctrl+RightArrow LeftArrow LeftArrow LeftArrow LeftArrow Ctrl+Delete Delete Ctrl+LeftArrow Ctrl+LeftArrow RightArrow RightArrow RightArrow u p d a t e Enter
UpArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow RightArrow RightArrow RightArrow RightArrow RightArrow Delete Enter
UpArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Ctrl+LeftArrow Shift+RightArrow Shift+RightArrow Shift+RightArrow Shift+RightArrow Delete - - p r e v i e w U p d a t e Escape
Exception
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'length')
at System.Text.StringBuilder.Remove(Int32 startIndex, Int32 length)
at Microsoft.PowerShell.PSConsoleReadLine.EditItemInsertChar.Undo()
at Microsoft.PowerShell.PSConsoleReadLine.RevertLine(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
Prepare the scene by recalling an earlier command at the prompt using the up-arrow. Press back-arrow to move cursor into the spot at which you want to inject text from earlier in the console readout. Scroll up, highlight text in the console readout. Right-click the console to reproduce the text at the current cursor location. Hit escape to clear the command at the prompt. Sit back and enjoy the exception.
Expected behavior
Escape should not raise an exception after right click injecting text from the console readout.
Actual behavior
- System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'length')Metadata
Metadata
Assignees
Labels
Resolution-DuplicateThere's another issue on the tracker that's pretty much the same thing.There's another issue on the tracker that's pretty much the same thing.
Activity
daxian-dbw commentedon Jun 10, 2020
Mavaddat Javid (@mavaddat) Didn't you already open #1495 for the same issue?
It was fixed by #1496, and is included in
2.1.0-beta2version of PSReadLine, which is available in PowerShell Gallery.mavaddat commentedon Jun 10, 2020
Oh geez. Is it the same issue? I assumed I had updated PSReadLine since then. Sorry.
daxian-dbw commentedon Jun 10, 2020
No worries, yeah I saw the new PS version, but the PSReadLine version is the same.
Install the
2.1.0-beta2from PowerShell Gallery and give it a try.mavaddat commentedon Jun 10, 2020
The bug is gone in
2.1.0-beta2. Thanks!daxian-dbw commentedon Jun 10, 2020
Be noted that the predictive suggestion feature is disabled by default in
2.1.0-beta2, you can turn it on bySet-PSReadLineOption -PredictionSource Historymavaddat commentedon Jun 10, 2020
You read my mind! I was literally just trying to figure out how to modulate this feature (turn it back on), reading this pull request thread about it and this sample
profile.ps1to achieve certain features.