From f686943eb40aa25e0a06837eeae6a907d9617d2b Mon Sep 17 00:00:00 2001 From: Matthew Rasmus Date: Thu, 27 Nov 2014 11:42:40 -0800 Subject: [PATCH] Fix crash in textinput --- components/script/textinput.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/script/textinput.rs b/components/script/textinput.rs index d39d22918c0..ed120aae943 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -295,6 +295,12 @@ impl TextInput { vec!(content) }; self.edit_point.line = min(self.edit_point.line, self.lines.len() - 1); - self.edit_point.index = min(self.edit_point.index, self.current_line_length() - 1); + + if self.current_line_length() == 0 { + self.edit_point.index = 0; + } + else { + self.edit_point.index = min(self.edit_point.index, self.current_line_length() - 1); + } } }