auto merge of #4648 : PeterReid/servo/issue4662, r=jdm

Fixes #4622

Previously, when the edit point was being clamped leftward by a shortened
line, it would be placed one one character too far to the left instead of
at the very end.

The "if" removed here was introduced in f686943eb4 to fix a crash, but the underlying reason for the crash was the incorrect "- 1", which has been there since the beginning ( 80764f65e3 ).
This commit is contained in:
bors-servo 2015-01-18 09:39:48 -07:00
commit 9844ec907e

View file

@ -357,13 +357,7 @@ impl TextInput {
vec!(content)
};
self.edit_point.line = min(self.edit_point.line, self.lines.len() - 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);
}
self.edit_point.index = min(self.edit_point.index, self.current_line_length());
}
}
@ -519,7 +513,6 @@ fn test_textinput_set_content() {
textinput.set_content("de".into_string());
assert_eq!(textinput.get_content().as_slice(), "de");
assert_eq!(textinput.edit_point.line, 0);
// FIXME: https://github.com/servo/servo/issues/4622.
assert_eq!(textinput.edit_point.index, 1);
assert_eq!(textinput.edit_point.index, 2);
}