Cannot register key handlers for the same key with different modifiers

Open
#3,555 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
csharp, powershell
Domain
cli

Research direction

Start by reproducing the behavior with the Set-PSReadLineKeyHandler commands from the issue, then trace the key-handler registration path in PSReadLine. Done means all listed modifier combinations register independently and an unmodified comma remains without a handler.

Written by the indexing model from the issue text.

Description

Area-KeyHandlers Issue-Bug
Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.
Exception report
N/A
Screenshot

image

Environment data
PS Version: 7.3.2
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.2.6
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 178
BufferHeight: 56
Steps to reproduce

Paste the following text:

Function Inject-Command([String] $command) {
	[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
	[Microsoft.PowerShell.PSConsoleReadLine]::Insert($command)
	[Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}

Set-PSReadLineKeyHandler -Chord "Ctrl+," -ScriptBlock { Inject-Command("echo success") }
Set-PSReadLineKeyHandler -Chord "Alt+," -ScriptBlock { Inject-Command("echo success") }
Set-PSReadLineKeyHandler -Chord "Shift+," -ScriptBlock { Inject-Command("echo success") }
Set-PSReadLineKeyHandler -Chord "Ctrl+Alt+." -ScriptBlock { Inject-Command("echo success") }
Set-PSReadLineKeyHandler -Chord "Ctrl+Shift+," -ScriptBlock { Inject-Command("echo success") }
Set-PSReadLineKeyHandler -Chord "Alt+Shift+," -ScriptBlock { Inject-Command("echo success") }
Set-PSReadLineKeyHandler -Chord "Ctrl+Alt+Shift+," -ScriptBlock { Inject-Command("echo success") }
  • Notice the first 4 handlers are able to be registered
  • Notice the remaining 3 handlers are not able to be registered
  • Type ,
  • Notice , is replaced with echo success (this handler was never registered)
Expected behavior
  • Each key handler should be able to be registered
  • Unmodified , should not have a handler registered
Actual behavior
  • Each key handler is not able to be able to be registered
  • Unmodified , has a handler registered
Dominant language
C#
Stars
4.4k
Forks
341
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PowerShell/PSReadLine

All issues in PowerShell/PSReadLine

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.