mirror of
https://github.com/PowerShell/PSReadLine
synced 2026-06-08 12:12:13 +00:00
Add bound check for the cursor top value to InvokePrompt (#4791)
This commit is contained in:
+13
-1
@@ -1035,16 +1035,28 @@ namespace Microsoft.PowerShell
|
||||
public static void InvokePrompt(ConsoleKeyInfo? key = null, object arg = null)
|
||||
{
|
||||
var console = _singleton._console;
|
||||
console.CursorVisible = false;
|
||||
|
||||
if (arg is int newY)
|
||||
{
|
||||
if (newY < 0 || newY >= console.BufferHeight)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(arg));
|
||||
}
|
||||
|
||||
console.CursorVisible = false;
|
||||
console.SetCursorPosition(0, newY);
|
||||
}
|
||||
else
|
||||
{
|
||||
newY = _singleton._initialY - _singleton._options.ExtraPromptLineCount;
|
||||
|
||||
// Silently return if user has implicitly requested an impossible prompt invocation.
|
||||
if (newY < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
console.CursorVisible = false;
|
||||
console.SetCursorPosition(0, newY);
|
||||
|
||||
// We need to rewrite the prompt, so blank out everything from a previous prompt invocation
|
||||
|
||||
Reference in New Issue
Block a user