aboutsummaryrefslogtreecommitdiff
path: root/src/input/tests.rs
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-08 01:23:23 +0300
committerGitHub <noreply@github.com>2026-04-08 01:23:23 +0300
commitd739880f438d88782b1bc0602b59c7ee4a0fe438 (patch)
tree193d29af2169b1f57d7552ae69785ff4b5d00e91 /src/input/tests.rs
parenta1b803ae64a8ef341356d7552e809c7c89f47b32 (diff)
parent53bb02b53720d00464843fa565850cbdef35aaad (diff)
Merge pull request #9 from Edmund-a7/master
fix: support IME input for Chinese and other UTF-8 characters
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 6482b245..d624d28a 100644
--- a/src/input/tests.rs
+++ b/src/input/tests.rs
@@ -720,3 +720,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());
+}