aboutsummaryrefslogtreecommitdiff
path: root/src/input/tests.rs
diff options
context:
space:
mode:
authoracumen7 <j18115025119@163.com>2026-04-07 20:52:24 +0800
committeracumen7 <j18115025119@163.com>2026-04-07 20:52:24 +0800
commit34bc876c665c0b5560766bc89dd6536aefce2cb7 (patch)
tree803d8b81b49ec8f54a82ac61b28763123e6e1e85 /src/input/tests.rs
parent78fc0721a3d014fe96e778c6bb452cfdfbe67603 (diff)
fix: support IME input for Chinese and other UTF-8 characters
Phase 1: UTF-8 encoding support - Modified encode_text_input() to handle characters without modifiers - Added unit tests for Chinese character encoding Phase 2: IME composition support - Removed REPORT_ALL_KEYS_AS_ESCAPE_CODES keyboard flag - Prevents keyboard protocol from interfering with IME - Allows digit keys to be captured by input method for candidate selection Fixes issue where IME input was not working properly. Supports Chinese, Japanese, Korean, and other UTF-8 input methods. Maintains compatibility with all existing features. Tested: - All 388 unit tests pass - Chinese IME input with pinyin works correctly - All navigate mode shortcuts work normally - All terminal applications work normally
Diffstat (limited to 'src/input/tests.rs')
-rw-r--r--src/input/tests.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/input/tests.rs b/src/input/tests.rs
index a3c71675..a5b4e8bd 100644
--- a/src/input/tests.rs
+++ b/src/input/tests.rs
@@ -707,3 +707,25 @@ fn protocol_from_nonzero_flags_is_kitty() {
KeyboardProtocol::Kitty { flags: 7 }
);
}
+
+#[test]
+fn chinese_char_encodes_as_utf8() {
+ let key = TerminalKey::new(KeyCode::Char('中'), KeyModifiers::empty());
+ let encoded = encode_terminal_key(key, KeyboardProtocol::Legacy);
+ assert_eq!(encoded, "中".as_bytes());
+}
+
+#[test]
+fn chinese_char_with_kitty_protocol_encodes_as_utf8() {
+ let key = TerminalKey::new(KeyCode::Char('文'), KeyModifiers::empty());
+ let encoded = encode_terminal_key(key, KeyboardProtocol::Kitty { flags: 7 });
+ assert_eq!(encoded, "文".as_bytes());
+}
+
+#[test]
+fn chinese_char_with_modifiers_falls_back_to_kitty_encoding() {
+ let key = TerminalKey::new(KeyCode::Char('测'), KeyModifiers::ALT);
+ let encoded = encode_terminal_key(key, KeyboardProtocol::Kitty { flags: 7 });
+ assert!(!encoded.is_empty());
+ assert_ne!(encoded, "测".as_bytes());
+}