Fix parsing hotkeys for non english chars#5122
Fix parsing hotkeys for non english chars#5122bn45hkurr0y4 wants to merge 2 commits intoPowerShell:masterfrom
Conversation
Add comments to clarify handling of Ctrl+letter combinations and dead keys.
There was a problem hiding this comment.
Pull request overview
This PR addresses a long-standing issue where Ctrl+letter hotkeys (notably Ctrl+C) can be mis-parsed under non-English Windows keyboard layouts (e.g., Russian), causing PSReadLine key binding matching to fail.
Changes:
- Skips the Windows
ToUnicodeEx-based translation for standard Ctrl+letter control characters (\x01–\x1A) to keep chord normalization layout-independent. - Adds inline comments explaining why Ctrl+letter chords should bypass layout-dependent translation to preserve key binding matching.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PSReadLine/Keys.cs
Outdated
| // to letters a-z is well-defined and layout-independent, so we skip the | ||
| // ToUnicodeEx call which would return a layout-dependent character | ||
| // (e.g. Cyrillic 'с' instead of Latin 'c' on Russian layout), breaking | ||
| // key binding matching. | ||
| if (!isDeadKey && !(c >= 1 && c <= 26)) |
There was a problem hiding this comment.
This change alters how Ctrl+letter chords are normalized on Windows, but there’s no automated coverage to prevent regressions (especially for non-English layouts like ru-RU). Please add a unit/integration test that validates Ctrl+C (and ideally a couple other Ctrl+letter chords) still normalize to the expected Latin chord string even when the active keyboard layout is Russian (skip the test if the layout isn’t available on the runner).
change magic number to hex Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This fixes an issue related to incorrect key handling in non-English keyboard layouts (in my case, the Russian CTRL + C shortcut).
I've had this problem for a long time and no one has fixed it yet, but with the help of AI, I discovered that the issue stems from incorrect handling of the Cyrillic alphabet.
Please test this patch, because I don’t know if it might affect something else and cause errors.
This fixes #1393 and #2865
PR Summary
PR Checklist
Microsoft Reviewers: Open in CodeFlow