fix(repl):blocks input of characters than 1 byte

This commit is contained in:
Cai BingJun 2023-02-05 10:47:45 +08:00
parent beed07ec35
commit 22ed2f65bb

View file

@ -142,6 +142,7 @@ impl StdinReader {
this.trim_matches(|c: char| c.is_whitespace())
.to_string()
.replace(['\n', '\r'], "")
.replace(|c: char| c.len_utf8() >= 2, "")
};
line.insert_str(position, &clipboard);
position += clipboard.len();
@ -226,6 +227,9 @@ impl StdinReader {
break;
}
(KeyCode::Char(c), _) => {
if c.len_utf8() >= 2{
continue;
}
line.insert(position, c);
position += 1;
}