Skip to content
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

Exception on non-Windows w/ command line w/ more lines than visible console buffer #663

Closed
bgshacklett opened this issue Apr 3, 2018 · 11 comments
Assignees
Labels
OutOfRange Issues relating to System.ArgumentOutOfRangeException

Comments

@bgshacklett
Copy link

Environment data

PS version: 6.0.2
PSReadline version: 2.0.0-beta1
os: Darwin BrianShlettsMBP.attlocal.net 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
PS file version:

Steps to reproduce or exception report

This occurred while attempting to paste in the Get-IniContent function at https://gallery.technet.microsoft.com/scriptcenter/ea40c1ef-c856-434b-b8fb-ebd7a76e8d91

Last 200 Keys:
 Space Space } Enter
 Space Space Space Space W r i t e - V e r b o s e Space " $ ( $ M y I n v o c a t i o n . M y C o m m a n d . N a m e ) : : Space F i n i s h e d Space P r o c e s s i n g Space f i l e : Space $ F i l e P a t h " Enter
 Space Space Space Space R e t u r n Space $ i n i Enter
 Space Space } Enter
 Enter
 Space Space E n d Enter
 Space Space { Enter
 Space Space Space Space W r i t e - V e r b o s e Space " $ ( $ M y I n v o c a t i o n . M y C o m m a n d . N a m e ) : : Space F u n c t i o n Space e n d e d " Enter
 Space Space } 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 -69.
   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(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
@lzybkr
Copy link
Member

lzybkr commented Apr 3, 2018

I don't have a Mac and I tried the same on Windows without an exception.

The stack you report is hit after nearly every single character, so I think there must be something very special about what was pasted and how.

Can you try to provide some more specifics, maybe reproduce the problem with a smaller piece of text? Without more information, this would be extremely difficult to fix.

@bgshacklett
Copy link
Author

Definitely. I've been planning to look into some of these Mac related issues myself. I just wanted to make sure I didn't forget about the issue before I had a chance.

@bgshacklett
Copy link
Author

bgshacklett commented Apr 6, 2018

After a fair amount of experimentation, I've found that this error occurs whenever the number of lines pasted without immediate execution is greater than the number of visible lines in the terminal window. I also found that it's reproducible in the standard Mac terminal and Hyper, as well.

Steps to reproduce:

  1. Open Terminal.app
  2. Note the number of lines in the terminal window by looking at the title bar of the window (the default should be 24).
  3. Enter <# on the first line and press the return key.
  4. Press the return key N times, where N is the number of lines visible in the terminal window (this should result in N+1 lines entered total).

I haven't gotten a chance to take a look at the code at all, yet, to see why this is occurring. I'll try to get to that soon.

@bgshacklett bgshacklett changed the title ArgumentOutOfRangeException on MacOS 10.13.3 under iTerm2 ArgumentOutOfRangeException on MacOS 10.13.3 Apr 6, 2018
@lzybkr lzybkr changed the title ArgumentOutOfRangeException on MacOS 10.13.3 Exception on non-Windows w/ command line w/ more lines than visible console buffer Apr 7, 2018
@lzybkr
Copy link
Member

lzybkr commented Apr 7, 2018

Thanks for narrowing down the problem - I can reproduce on Linux as well, I've updated the title accordingly.

@bgshacklett
Copy link
Author

Just another data point, I believe I'm experiencing this when listing available completions by pressing <Tab><Tab>:

Last 9 Keys:
 g e t - s s m Tab Tab

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 -26.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.PSConsoleReadLine.Menu.DrawMenu(Menu previousMenu)
   at Microsoft.PowerShell.PSConsoleReadLine.PossibleCompletionsImpl(CommandCompletion completions, Boolean menuSelect)
   at Microsoft.PowerShell.PSConsoleReadLine.CompleteImpl(Boolean menuSelect)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------
~> Get-SSM

Also, this may be obvious, but I'd rather include it just in case: I found that the value of the parameter top appears to be directly related to the number of lines which need to be drawn. If I increase the height of the terminal window so that the error reports Actual value was -1, I can prevent the error on the next try by increasing the terminal window's height by a single line.

@lzybkr
Copy link
Member

lzybkr commented Apr 30, 2018

I would call that a distinct bug with the same symptom. The fix will definitely be different - we should just display possible completions without using the menu if it doesn't fit on the screen.

@lzybkr lzybkr added this to the 2.0.0-beta2 milestone Apr 30, 2018
@SteveL-MSFT
Copy link
Member

I'm working on this one

@acmcg
Copy link

acmcg commented Jan 4, 2019

Get the same error cutting and pasting into the integrated console. If I kill the terminal windows using the 'bin' icon and restart it resumes working...

@joeyaiello joeyaiello added the OutOfRange Issues relating to System.ArgumentOutOfRangeException label Jun 18, 2019
@daxian-dbw daxian-dbw self-assigned this Jul 27, 2019
@iamkarlson
Copy link

iamkarlson commented Sep 11, 2019

Hi, did you have any time to look at this issue? it's quite persistent on all of my envs (mac, conemu, ssh to pwsh)

Edited:
Looks like it's fixed in pre-release. Thanks!

@msftrncs
Copy link
Collaborator

if not already fixed, its likely fixed by #979.

@daxian-dbw
Copy link
Member

Fixed by #979

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OutOfRange Issues relating to System.ArgumentOutOfRangeException
Projects
None yet
8 participants