Skip to content

ArgumentOutOfRangeException in Integrated Console when entering long input lines that wrap #702

Closed

Description

-- EDIT FROM THE MAINTAINERS --

The PowerShell Preview extension has PSReadLine support and should resolve this issue. If you're experiencing this, please give the preview extension a try. We've committed to delivering this fix in the stable extension release in January 2020.

-- ORIGINAL ISSUE --

An error occurred while reading input:

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 3000.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.EditorServices.Console.ConsoleReadLine.InsertInput(StringBuilder inputLine, Int32 promptStartCol, Int32 promptStartRow, String inser
tedInput, Int32 cursorIndex, Int32 insertIndex, Int32 replaceLength, Int32 finalCursorIndex)
   at Microsoft.PowerShell.EditorServices.Console.ConsoleReadLine.<ReadLine>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.PowerShell.EditorServices.Console.ConsoleService.<StartReplLoop>d__21.MoveNext()

Activity

  1. clmcgrath commented on Apr 28, 2017

    @clmcgrath
    Author
  2. daviwil commented on May 15, 2017

    @daviwil
    Contributor

    Thanks Chris! I'll take a look.

  3. changed the title [-]Exception Thrown when browsing command history in integrated terminal [/-] [+]ArgumentOutOfRangeException in Integrated Console when entering long input lines that wrap[/+] on May 16, 2017
  4. daviwil commented on May 17, 2017

    @daviwil
    Contributor

    Looks like this only happens when the output exceeds the Console.BufferHeight and the user types a line longer than the Console.WindowWidth. PSReadline solves this problem by scrolling the buffer:

    https://github.com/lzybkr/PSReadLine/blob/8e851bfadbbe7cd5d898b2f01eb6cf010f684a71/PSReadLine/Render.cs#L473

    The cross-platform implementation of ScrollBuffer is here:

    https://github.com/PowerShell/PowerShell/blob/7a55bf98b2370ab4817ab2533cb67673053ee446/src/Microsoft.PowerShell.PSReadLine/ConsoleLib.cs#L1055

    I'll implement the fix for this in June since it isn't a critical issue and only shows up in specific cases. Let me know if it is a big annoyance and I'll prioritize it sooner!

  5. clmcgrath commented on May 17, 2017

    @clmcgrath
    Author

    Does simply installing psreadline fix this because I have it installed unless the no profile switch added by vscode disables this

  6. daviwil commented on May 17, 2017

    @daviwil
    Contributor

    Nah, PSReadline doesn't work inside of the Integrated Console right now. Hoping to get that added in June.

  7. clmcgrath commented on May 17, 2017

    @clmcgrath
    Author
  8. daviwil commented on May 17, 2017

    @daviwil
    Contributor

    Me too!

  9. 89 remaining items

  10. TylerLeonhardt commented on Dec 21, 2019

    @TylerLeonhardt
    Member

    Goblenus your screenshot is of the PowerShell Stable extension. You want the "PowerShell Preview" extension. It's in the extension marketplace as well.

  11. msftrncs commented on Dec 21, 2019

    @msftrncs

    Goblenus, you are using an old version of PSReadLine. If you'd update to the latest 2.0.0-rc1 from PowerShellGallery, you will find that you do not need the PowerShell extension for Python (to the best of my knowledge). Even with the PowerShell Preview extension, you will need PSReadLine updated.

    See the PSReadLine repository for more info.

  12. Goblenus commented on Dec 21, 2019

    @Goblenus

    Carl Morris (@msftrncs) TylerLeonhardt I have just installed "PowerShell Preview" extension and check "PSReadLine" flag, but the same bug still happen.

    image

    Guys about this mess. I have no idea why I need installed "PowerShell Preview" extension, what is "PSReadLine" feature, I just want to start python debugging. Before it start to happen i haven't got installed "PowerShell Preview" or "PowerShell" extension. My last installation for vscode was "Visual Studio IntelliCode" with "Language Server".

    Q1: Why the first start of debugging is everything fine??
    Q2: Is i need installed "PowerShell" extension?
    Q3: Why was it begin to happen?

    One more thing, I have the solution (add "console": "integratedTerminal"), but what i done to make this bug happen.

  13. msftrncs commented on Dec 22, 2019

    @msftrncs

    Goblenus,

    Q1, I think it is because in order to step-debug python, the debugger needs to insure that the environment state is exactly the same between runs, so the second time, it is resetting various environment state, and the command, which is pasted in to PowerShell (more on this point) becomes very long, and triggers an issue in older version of PSReadLine.

    Q2, as far as I know, you should not need PowerShell Extension, as that is for PowerShell development. However, I think the Python extension expects to utilize PowerShell as the CLI environment for the Python debugger. PowerShell, and its command line input tool, PSReadLine preexist on Windows installations, but the Python extension may require PowerShell Core if being used on a Linux environment.

    I cannot understand Q3.

    Again, I do not think you need the PowerShell Extension for Python debugging, but I think you would benefit from upgrading PSReadLine to the latest version, and then revert your launch.json file so that it does not have the "console": "integratedTerminal" option.

    PowerShell is Microsoft's modern command line interface for Windows, now available on other operating systems as well. PSReadLine is an extension that improves the command line experience providing syntax highlighting, consistent multi-line command handling, enhanced history and more, that was originally a side project and is now a standard component of PowerShell. However, PSReadLine has gone through some issues as it has added more functionality, and most of those issues have only recently been fixed. The issue exception you commented with is one of the issues I know has been fixed in recent versions.

    Bottom line. If you are on Windows, become familiar with PowerShell, and upgrade PSReadLine to the current version via the instructions in the PSReadLine repository, and then I think your Python debugging issues will go away.

    Alternately, you could try the following in the PowerShell session that performs the debugging, remove-module psreadline and see if that helps or if it makes things worse. Don't worry, its a session level command and does not physically remove PSReadLine, its only removed until the current session ends.

  14. modified the milestones: , 2.0.0 on Jan 30, 2020
  15. SydneyhSmith commented on Feb 6, 2020

    @SydneyhSmith
    Collaborator

    Closing as PSReadLine is now available in the PowerShell Preview extension, which resolves this issue, tracking that PSReadLine is not available in the main PowerShell Extension here #1793

  16. mmac89 commented on Oct 10, 2020

    @mmac89

    Hey I am running into this issue every time I input a quotation mark in the integrated terminal in visual studio code, seems to be working fine in the windows powershell

  17. TylerLeonhardt commented on Oct 15, 2020

    @TylerLeonhardt
    Member

    Can you open a new issue Mathew MacElwee (@mmac89)? We've made some large changes to the code after this issue so what you're seeing is likely different than the cause of this issue.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions