mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
committed by
Jason Shirk
parent
0b7451bda3
commit
8d3f8537de
@@ -693,11 +693,18 @@ namespace Microsoft.PowerShell
|
||||
if (ParameterSetName.Equals(FunctionParameterSet))
|
||||
{
|
||||
var function = (string)_dynamicParameters.Value[FunctionParameter].Value;
|
||||
MethodInfo mi = typeof (PSConsoleReadLine).GetMethod(function);
|
||||
MethodInfo mi = typeof (PSConsoleReadLine).GetMethod(function,
|
||||
BindingFlags.Public | BindingFlags.Static | BindingFlags.IgnoreCase);
|
||||
|
||||
string functionName = mi.Name;
|
||||
|
||||
var keyHandler = (Action<ConsoleKeyInfo?, object>)
|
||||
mi.CreateDelegate(typeof (Action<ConsoleKeyInfo?, object>));
|
||||
BriefDescription = function;
|
||||
PSConsoleReadLine.SetKeyHandler(Chord, keyHandler, BriefDescription, Description);
|
||||
|
||||
string longDescription = PSReadLineResources.ResourceManager.GetString(
|
||||
functionName + "Description");
|
||||
|
||||
PSConsoleReadLine.SetKeyHandler(Chord, keyHandler, functionName, longDescription);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -79,8 +79,11 @@ namespace Microsoft.PowerShell
|
||||
// key should be first token to be popped
|
||||
if (key == 0)
|
||||
{
|
||||
// the keyChar is this token
|
||||
keyChar = token[0];
|
||||
// the keyChar is this token, if not a special key like "Fxx" etc.
|
||||
if (token.Length == 1)
|
||||
{
|
||||
keyChar = token[0];
|
||||
}
|
||||
|
||||
// Enum.TryParse accepts arbitrary integers. We shouldn't,
|
||||
// but single digits need to map to the correct key, e.g.
|
||||
|
||||
@@ -42,6 +42,12 @@ Describe "PSReadLine" -tags "CI" {
|
||||
(Get-PSReadLineKeyHandler | Where-Object { $_.Key -ceq "Alt+B" }).Function | Should Be SelectBackwardWord
|
||||
}
|
||||
|
||||
It "Should ignore case when using Function binding" {
|
||||
$lowerCaseFunctionName = "yank"
|
||||
Set-PSReadlineKeyHandler "Ctrl+F24" -Function $lowerCaseFunctionName
|
||||
(Get-PSReadlineKeyHandler | Where { $_.Key -eq "Ctrl+F24"}).Function | Should Be "Yank"
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
Remove-Module PSReadLine
|
||||
|
||||
|
||||
Reference in New Issue
Block a user