Skip to content

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

Closed

Description

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)

Activity

  1. lzybkr commented on Apr 3, 2018

    @lzybkr
    Contributor

    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.

  2. bgshacklett commented on Apr 4, 2018

    @bgshacklett
    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.

  3. bgshacklett commented on Apr 6, 2018

    @bgshacklett
    Author

    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.

  4. changed the title [-]ArgumentOutOfRangeException on MacOS 10.13.3 under iTerm2[/-] [+]ArgumentOutOfRangeException on MacOS 10.13.3[/+] on Apr 6, 2018
  5. changed the title [-]ArgumentOutOfRangeException on MacOS 10.13.3[/-] [+]Exception on non-Windows w/ command line w/ more lines than visible console buffer[/+] on Apr 7, 2018
  6. lzybkr commented on Apr 7, 2018

    @lzybkr
    Contributor

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

  7. bgshacklett commented on Apr 30, 2018

    @bgshacklett
    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.

  8. lzybkr commented on Apr 30, 2018

    @lzybkr
    Contributor

    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.

  9. SteveL-MSFT commented on May 28, 2018

    @SteveL-MSFT
    Member

    I'm working on this one

  10. acmcg commented on Jan 4, 2019

    @acmcg

    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...

  11. iamkarlson commented on Sep 11, 2019

    @iamkarlson

    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!

  12. msftrncs commented on Sep 11, 2019

    @msftrncs
    Collaborator

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

  13. daxian-dbw commented on Sep 12, 2019

    @daxian-dbw
    Member

    Fixed by #979

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

Metadata

Metadata

Labels

OutOfRangeIssues relating to System.ArgumentOutOfRangeException

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions