Skip to content

Garbage characters get inserted into the input line while pressing left right arrow keys #658

Closed
@jianyunt

Description

@jianyunt

By pressing and holding the left or right arrow keys you will see ascii sequence key code (OC, OD) gets inserted into your input string. The issue is reproducible on a Linux native terminal too. But on cloudshell it is easy to repro. The output looks like:

image

Initial Investigation

I am using the 2.0 PSReadline module. To repro it on Linux, I just run Register-EventObject to create a background job - that's what the cloudshell does for Azure token handling. It seems as long as a user has background jobs running, he will likely encounter the issue while pressing and holding Left and Right arrow keys or doing inputs on Linux machine.

  $Timer=New-Object Timers.Timer
  $Timer.Interval = 200
  $Timer.Enabled=$true
  foreach($I in 1..3){$job=Register-ObjectEvent -InputObject $Timer -EventName Elapsed -SourceIdentifier $i -Action {Get-Content /home/myname/pscore/powershell/build.psm1}}

It looks like the PSReadline is handling eventSubscribers. In this case, it found 3 subscribers so entered the code block from line 184 to 231. I am not sure what this code block is trying to archive, but if I comment them out, the issue disappears and all key press seems start working properly.

Environment data

image

Steps to reproduce or exception report

  • Ubuntu 16.04.1 LTS (Xenial Xerus) . Note I did not try on other distro
    or http//portal.azure.com and click on CloudShell

  • pwsh

  • run the above script to register some events if you are trying on your own Linux machine

  • type Hello and press and hold left or right arrow key

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