Psreadline: Pasting more than 200 characters into a PowerShell 5x session within Windows Terminal Version: 1.0.1811.0 causes an exception

Created on 19 Jul 2020  Β·  7Comments  Β·  Source: PowerShell/PSReadLine

The following statement will throw an exception in PowerShell terminal. This will not throw in the Windows PowerShell on V5 or V7.

catch {
if ($error.CategoryInfo.reason -eq 'PSRemotingTransportException') {
$exception = [exception]::new("You must enter credentials for the remote machine.")
$errorRecord = [System.Management.Automation.ErrorRecord]::new($exception, "Not Connected", "InvalidOperation", $null)
$PSCmdlet.ThrowTerminatingError($errorRecord)
}

Oops, something went wrong. Please report this bug with the details below.

Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new

Last 200 Keys:
r e m o t e Space m a c h i n e . " ) Tab Tab Enter
Tab Tab Tab $ e r r o r R e c o r d Space = Space [ S y s t e m . M a n a g e m e n t . A u t o m a t i o n . E r r o r R e c o r d ] : : n e w ( $ e x c e p t i o n , Space " N o t Space C o n n e c t e d " , Space " I n v a l i d O p e r a t i o n " , Space $ n u l l ) Enter
Tab Tab Tab $ P S C m d l e t . T h r o w T e r m i n a t i n g E r r o r ( $ e r r o r R e c o r d ) Enter
Tab Tab } Enter
Tab } Enter
} 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: top
Actual value was -22.
at System.Console.SetCursorPosition(Int32 left, Int32 top)
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(Nullable1 key, Object arg) at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

Resolution-Duplicate

All 7 comments

Which version is this throwing on? Your post makes it sound like it's neither throwing in v5 nor v7, so I'm confused as to what version is showing this issue. πŸ™‚

Works in regular windows powershell. Doesnt work in any version within powershell terminal.

Thanks
Dave

On Jul 19, 2020, at 11:26 AM, vexx32 notifications@github.com wrote:

ο»Ώ

Which version is this throwing on? Your post makes it sound like it's neither throwing in v5 nor v7, so I'm confused as to what version is showing this issue. πŸ™‚

β€”
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/PSReadLine/issues/1675#issuecomment-660663083, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJQPRPHMJNE3DQSTXH2PDVTR4MGCNANCNFSM4PBLQJYA.

What version of PSReadLine are you working with currently?

Here is the info. Seems to be reproducible by trying to cut and paste more than 200 characters at a time within Windows Terminal
Version: 1.0.1811.0 using a Windows Powershell 5.1 console. It doesn’t happen is 7.0.3 after I upgraded.

Name : PSReadline
Version : 2.0.0

$PSVersionTable from my host

Name Value
PSVersion 5.1.18362.752
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.752
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

PS>$error[1] | fl -for

ErrorRecord : The term 'prompt' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
CommandName : prompt
WasThrownFromThrowStatement : False
Message : The term 'prompt' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Data : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException :
TargetSite : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject]
Invoke(System.Collections.IEnumerable)
StackTrace : at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options)
HelpLink :
Source : System.Management.Automation
HResult : -2146233087

PS>$error[0].stacktrace
at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
at Microsoft.PowerShell.Executor.ExecuteCommandHelper(Pipeline tempPipeline, Exception& exceptionThrown, ExecutionOptions options)

PS>$error[0].stacktrace | fl -Force
Length : 218 <-- If I keep the count under 200 characters this will not happen.

PS>$error[1].CategoryInfo

Category : ObjectNotFound
Activity :
Reason : CommandNotFoundException
TargetName : prompt
TargetType : String

Thanks
Dave

From: vexx32 notifications@github.com
Sent: Sunday, July 19, 2020 3:15 PM
To: PowerShell/PSReadLine PSReadLine@noreply.github.com
Cc: Dave dgoldman@dgoldman.org; Author author@noreply.github.com
Subject: Re: [PowerShell/PSReadLine] Creating manual exception code in PowerShell terminal v5 causes an exception (#1675)

What version of PSReadLine are you working with currently?

β€”
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/PSReadLine/issues/1675#issuecomment-660693704, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJQPRPAHATLEBTN3YJUABSLR4NA4JANCNFSM4PBLQJYA.

Before we go too much further, I'd recommend updating to at least v2.0.2 of PSReadLine; I know there were a bunch of issues related to buffer handling that were fixed in 2.0.0 GA and subsequent patches. I'm not sure if you're using GA or the pre-release version there, but either way best first step is to see if it's still happening on the latest release πŸ™‚

That did the trick. It said I was running the rerelease in the psd1 and I just did an install-module so I can update it. Problem is gone. I guess we can close out the issue 😊

Thanks
Dave

From: vexx32 notifications@github.com
Sent: Sunday, July 19, 2020 6:48 PM
To: PowerShell/PSReadLine PSReadLine@noreply.github.com
Cc: Dave dgoldman@dgoldman.org; Author author@noreply.github.com
Subject: Re: [PowerShell/PSReadLine] Pasting more than 200 characters into a PowerShell 5x session within Windows Terminal Version: 1.0.1811.0 causes an exception (#1675)

Before we go too much further, I'd recommend updating to at least v2.0.2 of PSReadLine; I know there were a bunch of issues related to buffer handling that were fixed in 2.0.0 GA and subsequent patches. I'm not sure if you're using GA or the pre-release version there, but either way best first step is to see if it's still happening on the latest release πŸ™‚

β€”
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/PowerShell/PSReadLine/issues/1675#issuecomment-660720916, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AJQPRPGLQX2YJWVBAIEW6RTR4NZYVANCNFSM4PBLQJYA.

This issue was fixed (see #1306). Please upgrade to the 2.0.2 version of PSReadLine from PowerShellGallery. See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.

Was this page helpful?
0 / 5 - 0 ratings