Skip to content

Exception thrown when pressing escape in integrated PowerShell terminal #1959

@Zaph-x

Description

@Zaph-x

Environment

PSReadLine: 2.1.0-beta1
PowerShell: 7.1.0
OS: Microsoft Windows 10.0.19041
Last 200 Keys

 : \ P r o g r a m m i n g \ p 5 - p r o j e c t \ v e n v \ S c r i p t s \ p y t h o n . e x e ' Spacebar ' c : \ U s e r s \ M i k k e l \ . v s c o d e \ e x t e n s i o n s \ m s - p y t h o n . p y t h o n - 2 0 2 0 . 1 1 . 3 5 8 
3 6 6 0 2 6 \ p y t h o n F i l e s \ l i b \ p y t h o n \ d e b u g p y \ l a u n c h e r ' Spacebar ' 5 4 7 6 8 ' Spacebar ' - - ' Spacebar ' a p p . p y ' Spacebar ' - v ' Spacebar ' d e b u g ' Spacebar Enter
 UpArrow Escape

Exception

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'length')
   at System.Text.StringBuilder.Remove(Int32 startIndex, Int32 length)
   at Microsoft.PowerShell.PSConsoleReadLine.EditItemInsertChar.Undo()
   at Microsoft.PowerShell.PSConsoleReadLine.RevertLine(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)

Steps to reproduce

(This might be an issue linked to VSCode)

  • In VSCode run a python script with a launch debug configuration
  • Exit the script
  • Press up arrow to get last run command
    • Command should look something like cd 'e:\Programming\p5-project'; & 'e:\Programming\p5-project\venv\Scripts\python.exe' 'c:\Users\Mikkel\.vscode\extensions\ms-python.python-2020.11.358366026\pythonFiles\lib\python\debugpy\launcher' '54408' '--' 'app.py' '-v' 'debug'
  • Press Escape
  • Exception is thrown

Expected behavior

The line should clear, as it does normally, without throwing any exception

Actual behavior

Exception is thrown

It is possible this issue might be linked to #607 but doesn't seem like a duplicate

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions