Skip to content

PowerShell Preview: issue with host implementation dropping the first letter #1753

Closed
PowerShell/PowerShellEditorServices
#1072

Description

@sk82jack

System Details

VSCode version: 1.31.0 7c66f58312b48ed8ca4e387ebd9ffe9605332caa x64

VSCode extensions:

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

PSES version: 2.0.0.0

PowerShell version:

Name Value


PSVersion 5.1.17763.134
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.134
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

System Details Output


Issue Description

When prompting for input from the host (i.e. Read-Host or Get-Credential) the first letter that you type gets ignored resulting in the intended value of the command to be incorrect. It then writes the initial letter that got committed onto the next line in the console. Please see the gif below:

2019-02-08_22-45-22

Expected Behaviour

From the example in the gif I would expect the output of the command to be test and then have an empty line to continue typing commands.

Actual Behaviour

The example in the gif shows that the initial t typed is not registered as part of the input and so the command outputs est and then you can see the intial t is the written in the console on the next line.

Attached Logs

Haven't attached logs as it's not crashing but let me know if you need me to.

Activity

  1. SydneyhSmith commented on Feb 12, 2019

    @SydneyhSmith
    Collaborator

    sk82jack thanks for reporting this, it looks like this is a buffer issue likely caused by the PSReadLine implementation.
    Patrick Meinecke (@SeeminglyScience) any thoughts?

  2. SeeminglyScience commented on Feb 13, 2019

    @SeeminglyScience
    Collaborator

    Yeah I believe this is due to an incorrect assumption on my part. I had thought that if two threads were invoking Console.ReadKey(true) at the same time (on Windows at least) then both threads would get the same key at the same time. I thought I had tested that, but it appears I did not.

    A possible fix would be to use the same ReadKey override field we use for non-Windows to inject our ReadKey implementation.

  3. ili101 commented on Mar 31, 2019

    @ili101

    I can confirm that it is still a problem in preview 2.

  4. sba923 commented on Jun 19, 2019

    @sba923

    I confirm this issue; if I run the following script

    Write-Host -NoNewline ("Enter password: ")
    $password = Read-Host -AsSecureString
    
    
    $RIOM = [Runtime.InteropServices.Marshal]
    $bStr = $RIOM::SecureStringToBSTR($password)
    $ctpassword = $RIOM::PtrToStringAuto($bStr)
    $RIOM::ZeroFreeBSTR($bStr)
    
    Write-Host ("Password is: '{0}'" -f $ctpassword)
    
    Remove-Variable ctpassword
    

    and enter 12345 I get:

    image

  5. TylerLeonhardt commented on Oct 24, 2019

    @TylerLeonhardt
    Member

    I've got a PR out to fix this.

  6. ili101 commented on Nov 6, 2019

    @ili101

    Not fully fixed

    1. Copy something
    2. Run a file with Read-Host with F5
    3. Paste in console
      Paste
  7. ghost added
    Needs: Maintainer Attention
    on Nov 6, 2019
  8. TylerLeonhardt commented on Nov 6, 2019

    @TylerLeonhardt
    Member

    ili101 looks like that's dropping a few characters on paste. A different issue than this one. Can you open a new issue so we can track this separately?

  9. removed
    Needs: Maintainer Attention
    on Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-PSReadLineIssue-Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions