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

Handle ParameterBindingException for PowerShell 5.1 #176004

Merged

Conversation

andyleejordan
Copy link
Member

Which ships with PSReadLine 2.0.0 whose Get-PSReadLineKeyHandler function does not support -Chord. Easiest fix is catching the exception in that rare case and using -Bound and a filter to do the same thing.

Note that most people do upgrade PSReadLine, but there are cases where an inbox PowerShell 5.1 is being used without an update (and it may not always be updateable).

Interestingly Set-PSReadLineKeyHandler does have -Chord in this older version, so it can be left alone.

Fixes PowerShell/vscode-powershell#4409 (which should have been an upstream issue).

Which ships with PSReadLine 2.0.0 whose `Get-PSReadLineKeyHandler`
function does not support `-Chord`.
Easiest fix is catching the exception in that rare case and using
`-Bound` and a filter to do the same thing.

Note that most people do upgrade PSReadLine,
but there are cases where an inbox PowerShell 5.1 is being used
without an update (and it may not always be updateable).

Interestingly `Set-PSReadLineKeyHandler` does have `-Chord`
in this older version, so it can be left alone.
@andyleejordan
Copy link
Member Author

andyleejordan commented Mar 3, 2023

@Tyriar I checked with @daxian-dbw , the main PSReadLine developer (I try but he's the expert for sure) and he thought this was the best way to go too. Kudos to @DesuNinshu for figuring out the issue and suggesting the solution.

@andyleejordan
Copy link
Member Author

Tested (which for some reason getting VS Code built every time I go back to it is enormously difficult):

Screenshot 2023-03-02 at 8 17 04 PM

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙂

@Tyriar Tyriar enabled auto-merge March 10, 2023 23:17
@Tyriar Tyriar added this to the March 2023 milestone Mar 10, 2023
@Tyriar Tyriar assigned Tyriar and unassigned aiday-mar Mar 10, 2023
@Tyriar Tyriar merged commit 3bc06ff into microsoft:main Mar 10, 2023
@andyleejordan andyleejordan deleted the andschwa/set-mapped-key-handler branch March 11, 2023 00:23
@github-actions github-actions bot locked and limited conversation to collaborators Apr 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A parameter cannot be found that matches parameter name 'Chord'.
5 participants