<h1 dir="auto">Environment</h1>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Windows build number: Microsoft Windows [Version 10.0.18362.295]
Windows Terminal version (if applicable): Windows Terminal (Preview) Version: 0.5.2681.0"><pre lang="none" class="notranslate"><code class="notranslate">Windows build number: Microsoft Windows [Version 10.0.18362.295]
Windows Terminal version (if applicable): Windows Terminal (Preview) Version: 0.5.2681.0
</code></pre></div>
<h1 dir="auto">Steps to reproduce</h1>
<ol dir="auto">
<li>Install the latest (0.5.2681.0) windows terminal on windows 10 (1903), launch it and it works.</li>
<li>RDP (using window RDP tool) your system from another windows computer</li>
<li>Try to launch the windows terminal, it opens and crashed instantly</li>
</ol>
<h1 dir="auto">Expected behavior</h1>
<p dir="auto">Terminal should work while accessing it through RDP session</p>
<h1 dir="auto">Actual behavior</h1>
<p dir="auto">Terminal crashed with below given windows event log entry:<br>
Faulting application name: WindowsTerminal.exe, version: 1.0.1909.25001, time stamp: 0x5d8b1a61<br>
Faulting module name: TerminalControl.dll, version: 1.0.1909.25001, time stamp: 0x5d8b194b<br>
Exception code: 0xc0000409<br>
Fault offset: 0x0000000000052691<br>
Faulting process id: 0x1d3c<br>
Faulting application start time: 0x01d579d25edff7c0<br>
Faulting application path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.5.2681.0_x64__8wekyb3d8bbwe\WindowsTerminal.exe<br>
Faulting module path: C:\Program Files\WindowsApps\Microsoft.WindowsTerminal_0.5.2681.0_x64__8wekyb3d8bbwe\TerminalControl.dll<br>
Report Id: 98b3041c-8f29-4d12-a639-8deebd0f828f<br>
Faulting package full name: Microsoft.WindowsTerminal_0.5.2681.0_x64__8wekyb3d8bbwe<br>
Faulting package-relative application ID: App</p>
<h1 dir="auto">Environment</h1>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Windows build number: Windows 10 Insiders 18995 (until the next update)
Windows Terminal version: 0.5.2762.0

Any other software?
PowerShell: any version with PSReadLine
PSReadLine, 2.0.0 beta 2 through 5"><pre lang="none" class="notranslate"><code class="notranslate">Windows build number: Windows 10 Insiders 18995 (until the next update)
Windows Terminal version: 0.5.2762.0

Any other software?
PowerShell: any version with PSReadLine
PSReadLine, 2.0.0 beta 2 through 5
</code></pre></div>
<h1 dir="auto">Steps to reproduce</h1>
<p dir="auto">See also: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="501722825" data-permission-text="Title is private" data-url="https://github.com/PowerShell/PSReadLine/issues/1081" data-hovercard-type="issue" data-hovercard-url="/PowerShell/PSReadLine/issues/1081/hovercard" href="https://github.com/PowerShell/PSReadLine/issues/1081">PowerShell/PSReadLine#1081</a></p>
<ol dir="auto">
<li>Copy some script with multiple lines from somewhere, an editor like VS Code for instance, or even from the code section of this issue.</li>
<li>Use PowerShell with PSReadLine installed</li>
<li>Right-click paste in to the Windows Terminal session of PowerShell.</li>
</ol>
<p dir="auto">The issue will be amplified if the current cursor/prompt is already at the bottom of the window, as is shown below.</p>
<h1 dir="auto">Expected behavior</h1>
<p dir="auto">A paste to occur just as in Conhost.</p>
<h1 dir="auto">Actual behavior</h1>
<p dir="auto">Without PSReadLine loaded, this behavior will not be noticed, but this is just because PSReadLine uses CTRL-ENTER to insert lines past the cursor's position.</p>
<p dir="auto">CTRL-ENTER is getting pasted along with regular ENTER, causing PSReadLine to attempt to advance past the end of the buffer, causing an exception in SetCursorPosition, in addition to blank unnecessary lines.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/26179051/66089060-4550bf00-e543-11e9-8ef7-a28735b80d0e.png"><img src="https://user-images.githubusercontent.com/26179051/66089060-4550bf00-e543-11e9-8ef7-a28735b80d0e.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">What I pasted was:</p>
<div class="highlight highlight-source-powershell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="filter val_2_base33 ([int]$digits = 1) {
    # convert value to base 33 (VIN) string representation
    [int]$value = $_
    [string]$result = ''
    [int]$digs = 0
    while (++$digs -le $digits -or $value -gt 0) {
        $result = '0123456789ABCDEFGHJKLMNPRSTUVWXYZ'[$value % 33] + $result
        $value = [math]::Truncate($value / 33)
    }
    $result
}"><pre class="notranslate"><span class="pl-k">filter</span> <span class="pl-en">val_2_base33</span> ([<span class="pl-k">int</span>]<span class="pl-smi">$digits</span> <span class="pl-k">=</span> <span class="pl-c1">1</span>) {
    <span class="pl-c"><span class="pl-c">#</span> convert value to base 33 (VIN) string representation</span>
    [<span class="pl-k">int</span>]<span class="pl-smi">$value</span> <span class="pl-k">=</span> <span class="pl-c1">$_</span>
    [<span class="pl-k">string</span>]<span class="pl-smi">$result</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span><span class="pl-pds">'</span></span>
    [<span class="pl-k">int</span>]<span class="pl-smi">$digs</span> <span class="pl-k">=</span> <span class="pl-c1">0</span>
    <span class="pl-k">while</span> (<span class="pl-k">++</span><span class="pl-smi">$digs</span> <span class="pl-k">-le</span> <span class="pl-smi">$digits</span> <span class="pl-k">-or</span> <span class="pl-smi">$value</span> <span class="pl-k">-gt</span> <span class="pl-c1">0</span>) {
        <span class="pl-smi">$result</span> <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">'</span>0123456789ABCDEFGHJKLMNPRSTUVWXYZ<span class="pl-pds">'</span></span>[<span class="pl-smi">$value</span> <span class="pl-k">%</span> <span class="pl-c1">33</span>] <span class="pl-k">+</span> <span class="pl-smi">$result</span>
        <span class="pl-smi">$value</span> <span class="pl-k">=</span> [<span class="pl-k">math</span>]::Truncate(<span class="pl-smi">$value</span> <span class="pl-k">/</span> <span class="pl-c1">33</span>)
    }
    <span class="pl-smi">$result</span>
}</pre></div>
<p dir="auto">Problem doesn't seem to happen if using CTRL-V.</p>
<p dir="auto">I think the issue is that CTRL-ENTER aka CTRL-J aka LineFeed is contained in the clipboard copy of the data, and its not being filtered out when Right-Click paste.  Is there a reason for that, or is this an accident?</p>