Skip to content

ArgumentOutOfRangeException on VSCode terminal PS 7.0 #1758

New issue

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

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

Already on GitHub? Sign in to your account

Closed
jagdishrajan opened this issue Aug 17, 2020 · 8 comments
Closed

ArgumentOutOfRangeException on VSCode terminal PS 7.0 #1758

jagdishrajan opened this issue Aug 17, 2020 · 8 comments

Comments

@jagdishrajan
Copy link

Environment

PSReadLine: 2.0.2
PowerShell: 7.0.3
OS: Microsoft Windows 10.0.18362
Last 200 Keys

 n t e n t T y p e Spacebar " a p p l i c a t i o n / m s - e x c e l " Spacebar - A l l o w O v e r w r i t e = $ f a l s e Enter
 UpArrow Escape d g d g s t Tab Enter
 Spacebar Spacebar Spacebar Spacebar L i s t L o g Spacebar - C o n n S t r Spacebar ( G A S C o n n Spacebar X X X X X X X P r o d S t o r a g e C o n n ) Spacebar - P r e f i x Spacebar X X X X X X X X N i g h t l y R e p o r t A D L A P r o c e s s Spacebar - D a y s B a c k Spacebar 1 Enter
 Spacebar Spacebar Spacebar Spacebar L i s t L o g Spacebar - C o n n S t r Spacebar ( G A S C o

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 'top')
Actual value was 31.
   at System.ConsolePal.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.CalculateWhereAndWhatToRender(Boolean cursorMovedToInitialPos, RenderData renderData, LineInfoForRendering& lineInfoForRendering)    
   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)
@ghost ghost added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Aug 17, 2020
@tonybounty
Copy link

try to upgrade :
Install-Module -Name PSReadLine -Force

@juhoheinonen
Copy link

juhoheinonen commented Sep 3, 2020

Thanks @tonybounty it seems that upgrading PSReadLine fixed the issue for me. However, I had this problem in Windows Terminal, not in VSCode terminal.

@JoBrad
Copy link

JoBrad commented Sep 8, 2020

This doesn't seem to correct the issue when using the terminal in VSCode. Is this the correct place to report those errors, as well?

@juhoheinonen
Copy link

Yeah, that's true, this thread is about VSCode, not Windows Terminal. Sorry for a bit misplaced comment, I just was thankful to find solution to my problem.

@daxian-dbw
Copy link
Member

@jagdishrajan Sorry for not being able to get to this issue earlier. I know it's been a long time, but if it's possible, could you please answer a few questions below to help us investigate the exception?

  1. Do you have a repro for this issue? (a series of operations that will trigger this exception consistently)
  2. Can you run the following script to get some useful environment data?
& {
    $hostName = $Host.Name
    if ($hostName -eq "ConsoleHost" -and (Get-Command Get-CimInstance -ErrorAction SilentlyContinue)) {
        $id = $PID
        $inWindowsTerminal = $false
        while ($true) {
            $p = Get-CimInstance -ClassName Win32_Process -Filter "ProcessId Like $id"
            if (!$p -or !$p.Name) { break }
            if ($p.Name -eq "WindowsTerminal.exe") { $inWindowsTerminal = $true; break }
            $id = $p.ParentProcessId
        }
        if ($inWindowsTerminal) { $hostName += " (Windows Terminal)" }
    }

    "`nPS version: $($PSVersionTable.PSVersion)"
    $m = Get-Module PSReadline
    $v = $m.Version; $pre = $m.PrivateData.PSData.Prerelease
    if ($pre) { $v = "$v-$pre" }
    "PSReadline version: $v"
    if ($IsLinux -or $IsMacOS) {
        "os: $(uname -a)"
    } else {
        "os: $((dir $env:SystemRoot\System32\cmd.exe).VersionInfo.FileVersion)"
    }
    "PS file version: $($name = if ($PSVersionTable.PSEdition -eq "Core") { "pwsh.dll" } else { "powershell.exe" }; (dir $pshome\$name).VersionInfo.FileVersion)"
    "HostName: $hostName"
    "BufferWidth: $([console]::BufferWidth)"
    "BufferHeight: $([console]::BufferHeight)`n"
}

Thanks in advance for your help!

@jagdishrajan
Copy link
Author

@daxian-dbw, here are the results of the script. To be honest I haven't seen the error in a while, so I assume it got fixed in one of the updates to VSCode, where I typically run PowerShell.

PS version: 7.0.3
PSReadline version: 2.0.2
os: 10.0.18362.1 (WinBuild.160101.0800)
PS file version: 7.0.3.0
HostName: Visual Studio Code Host
BufferWidth: 177
BufferHeight: 32

@daxian-dbw
Copy link
Member

@jagdishrajan Thanks for sharing the environment data. Unfortunately, I cannot reproduce the exception with the Last 200 Keys shown in the exception report because I presume the output of the commands after pressing Enter also played a role since it changed the cursor top of the console.

Given that, I will close this issue for now. If you run into a similar exception in future, please kindly open another issue, with the exception output, environment data, and the repro steps (also a screenshot of the console right before the exception message if possible). That would be extremely helpful to our investigation. Thank you!

@ghost ghost removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Oct 13, 2020
@daxian-dbw
Copy link
Member

Mark this as a duplicate of #2298

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants