Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paste omits the hyphen character when using mouse right-click (Please RE-OPEN) #2715

Closed
5 tasks done
dennisl68-castra opened this issue Jul 30, 2021 · 5 comments
Closed
5 tasks done

Comments

@dennisl68-castra
Copy link

dennisl68-castra commented Jul 30, 2021

Prerequisites

Steps to reproduce

When pasting a command to the console using right-click, hyphens is always missing.

Please use the code below to generate a sample string for pasting into a PowerShell 7 console...

$step = [System.Convert]::FromBase64String(
    'IyAxLiBUbyBkaXNwbGF5IGEgbGlzdCBvZiBzZXJ2aWNlcyB0aGF0IHNob3dzIH' +
    'N0b3BwZWQgc2VydmljZXMgbGFzdCwgcnVuOgogICAgCkdldC1TZXJ2aWNlIHwg' +
    'ClNvcnQgU3RhdHVzIOKAk0Rlc2NlbmRpbmc='
)
[System.Text.Encoding]::UTF8.GetString($step)

Expected behavior

Get-Service |
Sort Status –Descending

<Mark, ENTER, RIGHT-CLICK>

Get-Service |
Sort Status –Descending

Actual behavior

Get-Service |
Sort Status –Descending

<Mark, ENTER, RIGHT-CLICK>

Get-Service |
Sort Status Descending

Error details

Exception             :
    Type              : System.Management.Automation.ParameterBindingException
    Message           : A positional parameter cannot be found that accepts argument 'Descending'.
    ParameterName     : Descending
    TypeSpecified     : string
    ErrorId           : PositionalParameterNotFound
    Line              : 2
    Offset            : 1
    CommandInvocation :
        MyCommand        : Sort-Object
        BoundParameters  :
            BoundPositionally :
                Length : 8
            Comparer          : System.OrdinalIgnoreCaseComparer
            Count             : 1
            Keys              :
                Length : 8
            Values            :
                Length      : 1
                LongLength  : 1
                Rank        : 1
                SyncRoot    :
                    Length : 6
                IsFixedSize : True
                Count       : 1
            SyncRoot          :
                BoundPositionally :
                    Length : 8
                Comparer          : System.OrdinalIgnoreCaseComparer
                Count             : 1
                Keys              :
                    Length : 8
                Values            :
                    Length      : 1
                    LongLength  : 1
                    Rank        : 1
                    SyncRoot    :
                        Length : 6
                    IsFixedSize : True
                    Count       : 1
                SyncRoot          :
                    BoundPositionally :
                        Length : 8
                    Comparer          : System.OrdinalIgnoreCaseComparer
                    Count             : 1
                    Keys              :
                        Length : 8
                    Values            :
                        Length      : 1
                        LongLength  : 1
                        Rank        : 1
                        SyncRoot    :
                            Length : 6
                        IsFixedSize : True
                        Count       : 1
                    SyncRoot          :
                        BoundPositionally :
                            Length : 8
                        Comparer          : System.OrdinalIgnoreCaseComparer
                        Count             : 1
                        Keys              :
                            Length : 8
                        Values            :
                            Length      : 1
                            LongLength  : 1
                            Rank        : 1
                            SyncRoot    :
                                Length : 6
                            IsFixedSize : True
                            Count       : 1
                        SyncRoot          :
                            BoundPositionally :
                                Length : 8
                            Comparer          : System.OrdinalIgnoreCaseComparer
                            Count             : 1
                            Keys              :
                                Length : 8
                            Values            :
                                Length      : 1
                                LongLength  : 1
                                Rank        : 1
                                SyncRoot    :
                                    Length : 6
                                IsFixedSize : True
                                Count       : 1
                            SyncRoot          :
                                BoundPositionally :
                                    Length : 8
                                Comparer          : System.OrdinalIgnoreCaseComparer
                                Count             : 1
                                Keys              :
                                    Length : 8
                                Values            :
                                    Length      : 1
                                    LongLength  : 1
                                    Rank        : 1
                                    SyncRoot    : …
                                    IsFixedSize : True
                                    Count       : 1
                                SyncRoot          :
                                    BoundPositionally : …
                                    Comparer          : System.OrdinalIgnoreCaseComparer
                                    Count             : 1
                                    Keys              : …
                                    Values            : …
                                    SyncRoot          : …
        ScriptLineNumber : 2
        OffsetInLine     : 1
        HistoryId        : 3
        Line             : Sort Status Descending
        PositionMessage  : At line:2 char:1
                           + Sort Status Descending
                           + ~~~~~~~~~~~~~~~~~~~~~~
        InvocationName   : Sort
        PipelineLength   : 2
        PipelinePosition : 2
        ExpectingInput   : True
    ErrorRecord       :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : A positional parameter cannot be found that accepts argument 'Descending'.
            HResult : -2146233087
        CategoryInfo          : InvalidArgument: (:) [Sort-Object], ParentContainsErrorRecordException
        FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SortObjectCommand
        InvocationInfo        :
            MyCommand        : Sort-Object
            ScriptLineNumber : 2
            OffsetInLine     : 1
            HistoryId        : 3
            Line             : Sort Status Descending
            PositionMessage  : At line:2 char:1
                               + Sort Status Descending
                               + ~~~~~~~~~~~~~~~~~~~~~~
            CommandOrigin    : Internal
        ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
    TargetSite        :
        Name          : VerifyArgumentsProcessed
        DeclaringType : System.Management.Automation.CmdletParameterBinderController, System.Management.Automation,
Version=7.1.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    StackTrace        :
   at System.Management.Automation.CmdletParameterBinderController.VerifyArgumentsProcessed(ParameterBindingException
originalBindingException)
   at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1
arguments)
   at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments)
   at System.Management.Automation.CommandProcessor.BindCommandLineParameters()
   at System.Management.Automation.CommandProcessor.Prepare(IDictionary psDefaultParameterValues)
   at System.Management.Automation.CommandProcessorBase.DoPrepare(IDictionary psDefaultParameterValues)
   at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream)
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
--- End of stack trace from previous location ---
   at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input)
   at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput,
CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][]
commandRedirections, FunctionContext funcContext)
   at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
    Data              : System.Collections.ListDictionaryInternal
    Source            : System.Management.Automation
    HResult           : -2146233087
CategoryInfo          : InvalidArgument: (:) [Sort-Object], ParameterBindingException
FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SortObjectCommand
InvocationInfo        :
    MyCommand        : Sort-Object
    ScriptLineNumber : 2
    OffsetInLine     : 1
    HistoryId        : 3
    Line             : Sort Status Descending
    PositionMessage  : At line:2 char:1
                       + Sort Status Descending
                       + ~~~~~~~~~~~~~~~~~~~~~~
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
get-module psreadline -ListAvailable

    Directory: C:\program files\powershell\7\Modules

ModuleType Version    PreRelease Name
---------- -------    ---------- ----
Script     2.1.0                 PSReadLine

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name
---------- -------    ---------- ----
Script     2.0.0      beta2      PSReadline

Visuals

image

@ghost ghost added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Jul 30, 2021
@dennisl68-castra
Copy link
Author

dennisl68-castra commented Jul 30, 2021

Tried updating to latest available on PSGallery (2.2.0, beta3).
The console still misses out on hyphens with PSReadline present.

I had to delete all versions of PSReadline, keeping only the one for Windows PowerShell 5.1 (v2.0.0 beta 2) to be able to paste text without loosing hyphens all over the place.

I did try installing the "stable" version of 2.0.0 and that has the same issue with pasting text :/

@daxian-dbw
Copy link
Member

@dennisl68-castra Please use the Ctrl+v key binding to do the pasting instead of the right click.

Animation

@ghost ghost removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Sep 9, 2021
@dennisl68-castra
Copy link
Author

dennisl68-castra commented Sep 23, 2021

Good call. I'll update the issue...

@dennisl68-castra dennisl68-castra changed the title Paste sometimes omits the hyphen character Paste omits the hyphen character when using mouse right-click Sep 23, 2021
@dennisl68-castra dennisl68-castra changed the title Paste omits the hyphen character when using mouse right-click Paste omits the hyphen character when using mouse right-click (Please RE-OPEN) Sep 23, 2021
@daxian-dbw
Copy link
Member

Right clicking is problematic, and there is no good way to handle it as of today, see #579. In PowerShell, it's recommended to use Ctrl+v, which is way faster than right click.

@dennisl68-castra
Copy link
Author

dennisl68-castra commented Sep 23, 2021

If it's faster is an opion of choice :)
Downgrading to psreadline v2.0.0 beta 2 makes it work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants