mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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 inf686943eb4
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:
commit
9844ec907e
1 changed files with 2 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue