windows: Only call TranslateMessage when we can't handle the event (#32166)

This PR improves key handling on Windows by moving the
`TranslateMessage` call from the message loop to after we handled
`WM_KEYDOWN`. This brings Windows behavior more in line with macOS and
gives us finer control over key events. As a result, Vim keybindings now
work properly even when an IME is active. The trade-off is that it might
introduce a slight delay in text input.


Release Notes:

- N/A
This commit is contained in:
张小白 2025-06-05 23:57:47 +08:00 committed by GitHub
parent 738cfdff84
commit 5b9d3ea097
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 48 additions and 34 deletions

View file

@ -231,9 +231,6 @@ impl WindowsPlatform {
}
}
_ => {
// todo(windows)
// crate `windows 0.56` reports true as Err
TranslateMessage(&msg).as_bool();
DispatchMessageW(&msg);
}
}