Skip to content

Commit d3eac09

Browse files
authored
Update docs to reflect the new -Chord parameter to Get-PSReadLineKeyHandler (#1438)
1 parent fcb2c9d commit d3eac09

File tree

3 files changed

+29
-15
lines changed

3 files changed

+29
-15
lines changed

PSReadLine/Options.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,10 @@ public static void RemoveKeyHandler(string[] key)
408408
{
409409
var boundFunctions = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
410410

411-
if (Chord == null) yield break;
411+
if (Chord == null || Chord.Length == 0)
412+
{
413+
yield break;
414+
}
412415

413416
foreach (string Key in Chord)
414417
{
@@ -445,16 +448,20 @@ public static void RemoveKeyHandler(string[] key)
445448
}
446449

447450
// If in Vi mode, also check Vi's command mode list.
448-
if (PSConsoleReadLine.GetOptions().EditMode == EditMode.Vi)
451+
if (_singleton._options.EditMode == EditMode.Vi)
449452
{
450453
if (_viCmdKeyMap.TryGetValue(firstKey, out entry))
451454
{
452455
if (consoleKeyChord.Length == 1)
453456
{
454-
if (entry.BriefDescription == "Ignore") continue;
457+
if (entry.BriefDescription == "Ignore")
458+
{
459+
continue;
460+
}
461+
455462
yield return new PowerShell.KeyHandler
456463
{
457-
Key = '<' + firstKey.KeyStr + '>',
464+
Key = "<" + firstKey.KeyStr + ">",
458465
Function = entry.BriefDescription,
459466
Description = entry.LongDescription,
460467
Group = GetDisplayGrouping(entry.BriefDescription),
@@ -466,10 +473,14 @@ public static void RemoveKeyHandler(string[] key)
466473
if (_viCmdChordTable.TryGetValue(firstKey, out var secondDispatchTable) &&
467474
secondDispatchTable.TryGetValue(secondKey, out entry))
468475
{
469-
if (entry.BriefDescription == "Ignore") continue;
476+
if (entry.BriefDescription == "Ignore")
477+
{
478+
continue;
479+
}
480+
470481
yield return new PowerShell.KeyHandler
471482
{
472-
Key = '<' + firstKey.KeyStr + "," + secondKey.KeyStr + '>',
483+
Key = "<" + firstKey.KeyStr + "," + secondKey.KeyStr + ">",
473484
Function = entry.BriefDescription,
474485
Description = entry.LongDescription,
475486
Group = GetDisplayGrouping(entry.BriefDescription),
@@ -479,8 +490,6 @@ public static void RemoveKeyHandler(string[] key)
479490
}
480491
}
481492
}
482-
yield break;
483-
484493
}
485494
}
486495
}

docs/Get-PSReadLineKeyHandler.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,23 @@ Gets the key bindings for the PSReadLine module.
1313

1414
```
1515
Get-PSReadLineKeyHandler [-Bound] [-Unbound]
16+
17+
Get-PSReadLineKeyHandler [-Chord] <String[]>
1618
```
1719

1820
## DESCRIPTION
1921

2022
Gets the key bindings for the PSReadLine module.
2123

22-
If neither -Bound nor -Unbound is specified, returns all bound keys functions.
24+
If no parameter is specified, returns all bound keys functions.
25+
26+
If '-Bound' is specified and '-Unbound' is not specified, only bound keys are returned.
2327

24-
If -Bound is specified and -Unbound is not specified, only bound keys are returned.
28+
If '-Unbound' is specified and '-Bound' is not specified, only unbound keys are returned.
2529

26-
If -Unbound is specified and -Bound is not specified, only unbound keys are returned.
30+
If both '-Bound' and '-Unbound' are specified, returns all bound keys and unbound functions.
2731

28-
If both -Bound and -Unbound are specified, returns all bound keys and unbound functions.
32+
If '-Chord' is specified, returns the specific bound keys.
2933

3034
## EXAMPLES
3135

@@ -58,7 +62,7 @@ Aliases:
5862

5963
Required: False
6064
Position: Named
61-
Default value: True
65+
Default value: False
6266
Accept pipeline input: false
6367
Accept wildcard characters: False
6468
```

docs/about_PSReadLine.help.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ LONG DESCRIPTION
107107
second is used if your binding is doing something more advanced with the Ast.
108108

109109
IEnumerable[Microsoft.PowerShell.KeyHandler] GetKeyHandlers(bool includeBound, bool includeUnbound)
110+
IEnumerable[Microsoft.PowerShell.KeyHandler] GetKeyHandlers(string[] Chord)
110111

111-
This function is used by Get-PSReadLineKeyHandler and probably isn't useful in a custom
112-
key binding.
112+
These two functions are used by Get-PSReadLineKeyHandler. The first is used to get all
113+
key bindings. The second is used to get specific key bindings.
113114

114115
Microsoft.PowerShell.PSConsoleReadLineOptions GetOptions()
115116

0 commit comments

Comments
 (0)