diff --git a/src/Microsoft.PowerShell.PSReadLine/Cmdlets.cs b/src/Microsoft.PowerShell.PSReadLine/Cmdlets.cs index 8549db3415..21a3ed15dc 100644 --- a/src/Microsoft.PowerShell.PSReadLine/Cmdlets.cs +++ b/src/Microsoft.PowerShell.PSReadLine/Cmdlets.cs @@ -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) mi.CreateDelegate(typeof (Action)); - BriefDescription = function; - PSConsoleReadLine.SetKeyHandler(Chord, keyHandler, BriefDescription, Description); + + string longDescription = PSReadLineResources.ResourceManager.GetString( + functionName + "Description"); + + PSConsoleReadLine.SetKeyHandler(Chord, keyHandler, functionName, longDescription); } else { diff --git a/src/Microsoft.PowerShell.PSReadLine/ConsoleKeyChordConverter.cs b/src/Microsoft.PowerShell.PSReadLine/ConsoleKeyChordConverter.cs index 6abaa815e5..bb34f27f92 100644 --- a/src/Microsoft.PowerShell.PSReadLine/ConsoleKeyChordConverter.cs +++ b/src/Microsoft.PowerShell.PSReadLine/ConsoleKeyChordConverter.cs @@ -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. diff --git a/test/powershell/Modules/PSReadLine/PSReadLine.Tests.ps1 b/test/powershell/Modules/PSReadLine/PSReadLine.Tests.ps1 index 081aef8690..26c9c21c7d 100644 --- a/test/powershell/Modules/PSReadLine/PSReadLine.Tests.ps1 +++ b/test/powershell/Modules/PSReadLine/PSReadLine.Tests.ps1 @@ -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