Skip to content

Commit c32edd7

Browse files
committed
Rename a couple parameters
1 parent b1d876a commit c32edd7

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

PSReadLine/Cmdlets.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ public class SetKeyHandlerCommand : PSCmdlet
186186
[ValidateNotNullOrEmpty]
187187
public string[] Chord { get; set; }
188188

189-
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "Custom")]
189+
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "ScriptBlock")]
190190
[ValidateNotNull]
191-
public ScriptBlock Handler { get; set; }
191+
public ScriptBlock ScriptBlock { get; set; }
192192

193-
[Parameter(ParameterSetName = "Custom")]
193+
[Parameter(ParameterSetName = "ScriptBlock")]
194194
public string BriefDescription { get; set; }
195195

196-
[Parameter(ParameterSetName = "Custom")]
196+
[Parameter(ParameterSetName = "ScriptBlock")]
197197
public string LongDescription { get; set; }
198198

199199
// ValidateSet attribute is generated by the script GenerateBuiltinList
@@ -206,23 +206,23 @@ public class SetKeyHandlerCommand : PSCmdlet
206206
"PossibleCompletions", "PreviousHistory", "Redo", "RevertLine", "SetKeyHandler",
207207
"SetMark", "TabCompleteNext", "TabCompletePrevious", "Undo", "Yank",
208208
"YankPop")]
209-
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "Builtin")]
210-
public string Builtin { get; set; }
209+
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "Function")]
210+
public string Function { get; set; }
211211

212212
[ExcludeFromCodeCoverage]
213213
protected override void EndProcessing()
214214
{
215215
Action<ConsoleKeyInfo?, object> keyHandler;
216-
if (ParameterSetName.Equals("Builtin"))
216+
if (ParameterSetName.Equals("Function"))
217217
{
218218
keyHandler = (Action<ConsoleKeyInfo?, object>)
219219
Delegate.CreateDelegate(typeof (Action<ConsoleKeyInfo?, object>),
220-
typeof (PSConsoleReadLine).GetMethod(Builtin));
221-
BriefDescription = Builtin;
220+
typeof (PSConsoleReadLine).GetMethod(Function));
221+
BriefDescription = Function;
222222
}
223223
else
224224
{
225-
keyHandler = (key, arg) => Handler.Invoke(key, arg);
225+
keyHandler = (key, arg) => ScriptBlock.Invoke(key, arg);
226226
}
227227
PSConsoleReadLine.SetKeyHandler(Chord, keyHandler, BriefDescription, LongDescription);
228228
}

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,16 @@ There are many configuration options, see the options to Set-PSReadlineOption.
4343
To set your own custom keybindings, use the cmdlet Set-PSReadlineKeyHandler. For example, for a better history experience, try:
4444

4545
```powershell
46-
Set-PSReadlineKeyHandler -Key UpArrow -BriefDescription HistorySearchBackward -Handler {
47-
[PSConsoleUtilities.PSConsoleReadLine]::HistorySearchBackward()
48-
}
49-
Set-PSReadlineKeyHandler -Key DownArrow -BriefDescription HistorySearchForward -Handler {
50-
[PSConsoleUtilities.PSConsoleReadLine]::HistorySearchForward()
51-
}
46+
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
47+
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
5248
```
5349

5450
With these bindings, up arrow/down arrow will work like PowerShell/cmd if the current command line is blank. If you've entered some text though, it will search the history for commands that start with the currently entered text.
5551

5652
To enable bash style completion without using Emacs mode, you can use:
5753

5854
```powershell
59-
Set-PSReadlineKeyHandler -Key Tab -BriefDescription Complete -Handler {
60-
[PSConsoleUtilities.PSConsoleReadLine]::Complete()
61-
}
55+
Set-PSReadlineKeyHandler -Key Tab -Function Complete
6256
```
6357

6458
See the public methods of [PSConsoleUtilities.PSConsoleReadLine] to see what other built-in functionality you can modify.

0 commit comments

Comments
 (0)