From 1c9ae5410a0024075e493d8ac4b7d28df045f33a Mon Sep 17 00:00:00 2001 From: bn45hkurr0y4 Date: Wed, 8 Apr 2026 11:41:55 +0200 Subject: [PATCH 1/2] Improve comments for key handling logic Add comments to clarify handling of Ctrl+letter combinations and dead keys. --- PSReadLine/Keys.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/PSReadLine/Keys.cs b/PSReadLine/Keys.cs index 70cd80e47..54bc38e81 100644 --- a/PSReadLine/Keys.cs +++ b/PSReadLine/Keys.cs @@ -245,7 +245,12 @@ void AppendPart(string str) // another special key, such as 'Ctrl+?' and 'Ctrl+;'. isDeadKey = (c == '\0') && (consoleKey >= ConsoleKey.Oem1 && consoleKey <= ConsoleKey.Oem102) && !isCtrl; - if (!isDeadKey) + // For standard Ctrl+letter combinations (KeyChar \x01-\x1A), the mapping + // 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)) { // A dead key could pass the above heuristic check, such as 'Shift+6' in US-INTL keyboard, which represents the // diacritic '^' and generates 'D6' ConsoleKey, '\0' key char and 'Shift' modifier. From 1533ae2706f36d9172baa91b9023bc1b06701488 Mon Sep 17 00:00:00 2001 From: bn45hkurr0y4 Date: Wed, 8 Apr 2026 12:18:29 +0200 Subject: [PATCH 2/2] Update PSReadLine/Keys.cs change magic number to hex Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- PSReadLine/Keys.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PSReadLine/Keys.cs b/PSReadLine/Keys.cs index 54bc38e81..ae1f649cc 100644 --- a/PSReadLine/Keys.cs +++ b/PSReadLine/Keys.cs @@ -250,7 +250,7 @@ void AppendPart(string str) // 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)) + if (!isDeadKey && !(c >= '\x01' && c <= '\x1A')) { // A dead key could pass the above heuristic check, such as 'Shift+6' in US-INTL keyboard, which represents the // diacritic '^' and generates 'D6' ConsoleKey, '\0' key char and 'Shift' modifier.