Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions PSReadLine/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,10 @@ public static void RemoveKeyHandler(string[] key)
{
var boundFunctions = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

if (Chord == null) yield break;
if (Chord == null || Chord.Length == 0)
{
yield break;
}

foreach (string Key in Chord)
{
Expand Down Expand Up @@ -445,16 +448,20 @@ public static void RemoveKeyHandler(string[] key)
}

// If in Vi mode, also check Vi's command mode list.
if (PSConsoleReadLine.GetOptions().EditMode == EditMode.Vi)
if (_singleton._options.EditMode == EditMode.Vi)
{
if (_viCmdKeyMap.TryGetValue(firstKey, out entry))
{
if (consoleKeyChord.Length == 1)
{
if (entry.BriefDescription == "Ignore") continue;
if (entry.BriefDescription == "Ignore")
{
continue;
}

yield return new PowerShell.KeyHandler
{
Key = '<' + firstKey.KeyStr + '>',
Key = "<" + firstKey.KeyStr + ">",
Function = entry.BriefDescription,
Description = entry.LongDescription,
Group = GetDisplayGrouping(entry.BriefDescription),
Expand All @@ -466,10 +473,14 @@ public static void RemoveKeyHandler(string[] key)
if (_viCmdChordTable.TryGetValue(firstKey, out var secondDispatchTable) &&
secondDispatchTable.TryGetValue(secondKey, out entry))
{
if (entry.BriefDescription == "Ignore") continue;
if (entry.BriefDescription == "Ignore")
{
continue;
}

yield return new PowerShell.KeyHandler
{
Key = '<' + firstKey.KeyStr + "," + secondKey.KeyStr + '>',
Key = "<" + firstKey.KeyStr + "," + secondKey.KeyStr + ">",
Function = entry.BriefDescription,
Description = entry.LongDescription,
Group = GetDisplayGrouping(entry.BriefDescription),
Expand All @@ -479,8 +490,6 @@ public static void RemoveKeyHandler(string[] key)
}
}
}
yield break;

}
}
}
14 changes: 9 additions & 5 deletions docs/Get-PSReadLineKeyHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ Gets the key bindings for the PSReadLine module.

```
Get-PSReadLineKeyHandler [-Bound] [-Unbound]

Get-PSReadLineKeyHandler [-Chord] <String[]>
```

## DESCRIPTION

Gets the key bindings for the PSReadLine module.

If neither -Bound nor -Unbound is specified, returns all bound keys functions.
If no parameter is specified, returns all bound keys functions.

If '-Bound' is specified and '-Unbound' is not specified, only bound keys are returned.

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

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

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

## EXAMPLES

Expand Down Expand Up @@ -58,7 +62,7 @@ Aliases:

Required: False
Position: Named
Default value: True
Default value: False
Accept pipeline input: false
Accept wildcard characters: False
```
Expand Down
5 changes: 3 additions & 2 deletions docs/about_PSReadLine.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ LONG DESCRIPTION
second is used if your binding is doing something more advanced with the Ast.

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

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

Microsoft.PowerShell.PSConsoleReadLineOptions GetOptions()

Expand Down