Skip to content

Commit 1c9ae54

Browse files
authored
Improve comments for key handling logic
Add comments to clarify handling of Ctrl+letter combinations and dead keys.
1 parent caa53f8 commit 1c9ae54

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

PSReadLine/Keys.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,12 @@ void AppendPart(string str)
245245
// another special key, such as 'Ctrl+?' and 'Ctrl+;'.
246246
isDeadKey = (c == '\0') && (consoleKey >= ConsoleKey.Oem1 && consoleKey <= ConsoleKey.Oem102) && !isCtrl;
247247

248-
if (!isDeadKey)
248+
// For standard Ctrl+letter combinations (KeyChar \x01-\x1A), the mapping
249+
// to letters a-z is well-defined and layout-independent, so we skip the
250+
// ToUnicodeEx call which would return a layout-dependent character
251+
// (e.g. Cyrillic 'с' instead of Latin 'c' on Russian layout), breaking
252+
// key binding matching.
253+
if (!isDeadKey && !(c >= 1 && c <= 26))
249254
{
250255
// A dead key could pass the above heuristic check, such as 'Shift+6' in US-INTL keyboard, which represents the
251256
// diacritic '^' and generates 'D6' ConsoleKey, '\0' key char and 'Shift' modifier.

0 commit comments

Comments
 (0)