From 6a9a512db862d26ceaf16cb88939f3275384d14c Mon Sep 17 00:00:00 2001 From: marc2332 Date: Wed, 9 Aug 2023 23:01:10 +0200 Subject: [PATCH] use_editable fix --- hooks/src/text_editor.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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 + } + } } } }