diff --git a/hooks/src/text_editor.rs b/hooks/src/text_editor.rs index 53ff1753f..efdc3b7f3 100644 --- a/hooks/src/text_editor.rs +++ b/hooks/src/text_editor.rs @@ -359,12 +359,17 @@ pub trait TextEditor: Sized + Clone + Display { event = TextEvent::TextChanged } _ => { - // Adds a new character - let char_idx = self.line_to_char(self.cursor_row()) + self.cursor_col(); - self.insert(character, char_idx); - self.cursor_right(); - - event = TextEvent::TextChanged + if let Ok(ch) = character.parse::() { + if ch.is_ascii_alphanumeric() { + // Adds a new character + let char_idx = + self.line_to_char(self.cursor_row()) + self.cursor_col(); + self.insert(character, char_idx); + self.cursor_right(); + + event = TextEvent::TextChanged + } + } } } }