Skip to content
New issue

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

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

Already on GitHub? # to your account

Setting prompt to a single char seems to cause Out-of-range #971

Closed
jhoneill opened this issue Jul 20, 2019 · 2 comments
Closed

Setting prompt to a single char seems to cause Out-of-range #971

jhoneill opened this issue Jul 20, 2019 · 2 comments
Labels
Issue-Question For non-bug questions or discussion.

Comments

@jhoneill
Copy link

Not 100 % sure, but when I wanted to hide my normal prompt and defined
function prompt {">"}
I got a series of errors and requests to post the dump here, when I changed back to the normal prompt the errors stopped.

Environment PSReadLine: 2.0.0-beta4

PowerShell: 7.0.0-preview.2
OS: Microsoft Windows 10.0.18362
Last 200 Keys

 m p Backspace Backspace Backspace Backspace Backspace p Backspace p r o m p t Spacebar " Ctrl+v Backspace Backspace Backspace Escape Escape Escape Escape Enter
 u Backspace Backspace f u n c t i o n Spacebar p r o m p t Spacebar " > " } LeftArrow LeftArrow LeftArrow LeftArrow { Enter
 c l s Enter
 UpArrow UpArrow UpArrow Enter
 UpArrow UpArrow UpArrow UpArrow Enter
 Shift+UpArrow Shift+UpArrow Shift+UpArrow Shift+UpArrow Shift+UpArrow Shift+UpArrow Shift+UpArrow Shift+UpArrow Shift+UpArrow Shift+UpArrow F7 F7 f u n c t u n Backspace Backspace Backspace i o n Spacebar Backspace Backspace Backspace Backspace t i o n f u n c t i o n f < t > Enter
 UpArrow UpArrow UpArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow DownArrow f u n c t i o Spacebar n f Spacebar Backspace Backspace Backspace Backspace n f u n c t i o n c d Spacebar d o c Tab w i n Tab Enter
 d e l Spacebar Backspace Backspace Backspace Backspace Backspace c d Spacebar Backspace Backspace Backspace Backspace . Tab Tab Tab Backspace Backspace Backspace Enter
 . p r o f i l e Tab Enter
 .

Exception

System.ArgumentOutOfRangeException: The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: left
Actual value was -1.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at System.Console.set_CursorLeft(Int32 value)
   at Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(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)
@lzybkr
Copy link
Member

lzybkr commented Jul 22, 2019

The exception was fixed in #967.

That said, you'll still see weird rendering issues until you update the PromptText setting. At startup, PSReadLine looks at your prompt function and infers what the end of your prompt looks like (if it can, which works with the default prompt).

If you change your prompt, this setting will no longer be valid and you can change it with:

Set-PSReadLineOption -PromptText ">"

or whatever text at the end of your prompt changed to red when there is an error. Or set it to the empty string if you don't want the prompt changing colors.

@lzybkr lzybkr added the Issue-Question For non-bug questions or discussion. label Jul 22, 2019
@daxian-dbw
Copy link
Member

Close the issue since the exception was fixed.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Issue-Question For non-bug questions or discussion.
Projects
None yet
Development

No branches or pull requests

3 participants