Skip to content

fix(win32): '~' followed by '/' only outputs '~' - #17

Merged
shiweis merged 3 commits into
shiweis:mainfrom
tberta:win32/dead-key-multi-char
Oct 29, 2026
Merged

shiweis merged 3 commits into
shiweis:mainfrom
tberta:win32/dead-key-multi-char

Conversation

@tberta

@tberta tberta commented Oct 29, 2026 •

Copy link
Copy Markdown

On dead-key layouts, ToUnicode can return multiple UTF-16 units for one press, such as ~/. Keeping only the first unit dropped text in Win32 Input Mode.

Preserve every valid returned unit within the supplied buffer. Generated prefix/continuation text follows the existing neutral Win32 character-event path, while each logical physical press retains its virtual key, scan code, modifiers, and eventual key-up. Re-translate coalesced repeats after dead-key composition, preserve surrogate/ligature ordering, and clear tracked dead-key state on focus loss. Ordinary character and non-text events retain compact repeat counts.

Added a deterministic regression that injects translation/key-state results and checks the actual I/O mailbox packets. It covers non-combining and composed dead keys, coalesced repeats of dead keys and ordinary keys, surrogate pairs, ligatures, modifiers, releases, buffer bounds/trailing data, keyboard-state failure, focus reset, and read-only input. It needs no live keyboard input or layout changes.

Focused filter: Win32 Input Mode preserves translated text without replaying physical keys. The contributor also reported manual French-layout verification in WSL, PowerShell, and cmd.exe.

Additional native consumer verification: all 10 raw ReadConsoleInputW cases passed through the bundled ConPTY, including baseline repeat shapes, generated prefix text, composed/literal repeats, surrogate pairs, ligatures, modifiers, and release records. A Console.ReadKey repeat quirk reproduces with the unchanged original single-packet baseline in both PowerShell 5.1 and 7; the encoder keeps the correct Win32 repeat counts. This verifies packet interpretation, not live physical keyboard-layout translation.

The final combined candidate passed selected Windows callback/wire tests (86 passed, one platform declaration skipped), debug and stripped fast builds, and the 21-check tab/session UI regression.

A dead key followed by a non-combining key (e.g. '~' then '/') makes
ToUnicode return two UTF-16 units. Only the first was forwarded, so
PowerShell via ConPTY received '~' without '/'. Send one event per unit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tberta tberta changed the title win32: send every char of a dead-key result in Win32 Input Mode fix(win32): '~' followed by '/' only outputs '~' Oct 29, 2026
Keep additional dead-key and ligature text neutral, preserve surrogate ordering across repeats, and retranslate coalesced repetitions after consuming a dead key. Track the native dead-key state through both encoders and clear it on focus loss. Exercise complete PTY input packets with a fake native translator, without desktop-global input or keyboard-layout changes.
@shiweis
shiweis merged commit cf6e0fd into shiweis:main Oct 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants