diff options
author | 2020-03-13 17:54:02 +0100 | |
---|---|---|
committer | 2020-03-13 17:54:02 +0100 | |
commit | 731e6752eb2130fb4ff2b92fd9c3274ea1b3110d (patch) | |
tree | b874136755d476624fe7442b0f0112519e3539cc /native/src/widget | |
parent | 767096b9bbe091f6fed2a3ff31a4c6cc1131ecea (diff) | |
download | iced-731e6752eb2130fb4ff2b92fd9c3274ea1b3110d.tar.gz iced-731e6752eb2130fb4ff2b92fd9c3274ea1b3110d.tar.bz2 iced-731e6752eb2130fb4ff2b92fd9c3274ea1b3110d.zip |
keep cursor inside value boundaries more reliable
Diffstat (limited to 'native/src/widget')
-rw-r--r-- | native/src/widget/text_input.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index 68fd7dfb..82406b5a 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -324,7 +324,7 @@ where } _ => (), } - self.value.insert(self.state.cursor.end(), c); + self.value.insert(self.state.cursor.end().min(self.value.len()), c); self.state.cursor.move_right(&self.value); let message = (self.on_change)(self.value.to_string()); @@ -347,11 +347,11 @@ where self.state.cursor.move_left(); } None => { - if self.state.cursor.start() > 0 { + if self.state.cursor.start().min(self.value.len()) > 0 { self.state.cursor.move_left(); let _ = self .value - .remove(self.state.cursor.start() - 1); + .remove(self.state.cursor.start()); } } } |