diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-25 17:23:01 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-25 17:23:01 +0300 |
| commit | 7811d84f15f1b2e41d68901d368791b15e0bf6c7 (patch) | |
| tree | 7affd2110a08f101dbce0779b68adbd6bdd39ef2 /src/client | |
| parent | 2ff5dd2f40324ed63f8b424bce1954f2fdca6f84 (diff) | |
fix: ignore modifier-only windows input
refs #795
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/input/windows_vti.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/client/input/windows_vti.rs b/src/client/input/windows_vti.rs index 9f6d3788..10e1d76b 100644 --- a/src/client/input/windows_vti.rs +++ b/src/client/input/windows_vti.rs @@ -496,6 +496,9 @@ impl WindowsInputMapper { if !self.key_record_can_emit_event(key) { return Vec::new(); } + if Self::key_record_is_modifier_only(key) { + return Vec::new(); + } if key.virtual_key_code == 0 { if let Some((_bytes, event)) = @@ -520,6 +523,13 @@ impl WindowsInputMapper { key.key_down || Self::is_alt_code(key) || key.virtual_key_code != 0 } + fn key_record_is_modifier_only(key: WindowsKeyRecord) -> bool { + matches!( + key.virtual_key_code, + 0x10 | 0x11 | 0x12 | 0xa0 | 0xa1 | 0xa2 | 0xa3 | 0xa4 | 0xa5 + ) && key.unicode == 0 + } + fn is_alt_code(key: WindowsKeyRecord) -> bool { const VK_MENU: u16 = 0x12; key.virtual_key_code == VK_MENU && !key.key_down && key.unicode != 0 @@ -1111,6 +1121,25 @@ mod tests { } #[test] + fn vti_modifier_only_key_records_do_not_emit_terminal_input() { + let modifier_records = [ + key_vk_with_utf16_mods(0x11, 0, 0x0008), + key_vk_with_utf16_mods(0xa2, 0, 0x0008), + key_vk_with_utf16_mods(0xa3, 0, 0x0004), + key_vk_with_repeat(0x11, 3), + ]; + + assert!(translate(modifier_records).is_empty()); + } + + #[test] + fn vti_win32_input_mode_modifier_only_key_records_do_not_emit_terminal_input() { + let records = "\x1b[17;0;0;1;8;3_".chars().map(key_char); + + assert!(translate(records).is_empty()); + } + + #[test] fn vti_real_non_letter_control_records_are_preserved() { let cases = [ (0x20, 0x00, ' '), |
