question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Right-click earlier text in console readout, then hit `escape` causes exception

See original GitHub issue

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')

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
daxian-dbwcommented, Jun 10, 2020

Be noted that the predictive suggestion feature is disabled by default in 2.1.0-beta2, you can turn it on by Set-PSReadLineOption -PredictionSource History

0reactions
mavaddatcommented, Jun 10, 2020

Be noted that the predictive suggestion feature is disabled by default in 2.1.0-beta2, you can turn it on by Set-PSReadLineOption -PredictionSource History

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.ps1 to achieve certain features.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Console output when Console.ReadKey ...
But there is a issue: When the user cancels the input (hits Escape), the first character of the following Console.WriteLine is suppressed, and...
Read more >
Serial Terminal Basics - SparkFun Learn
This tutorial is here to help you understand what these terms mean and how they form the larger picture that is serial communication...
Read more >
Developing Python Web Applications with Flask
To run the Python-Flask Webapp, right-click on the Flask script ⇒ Run As ⇒ Python Run. The following message appears on the console:...
Read more >
Changelog | Input System | 1.4.4
When exceptions occur in user code inside of Input System callbacks, the exception message is now printed first and details about the ...
Read more >
DataMan® Communications and Programming Guide
In case the DMCC set command for the IP address fails, a non-zero status will be returned, and a script exception will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found