aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/textinput.rs
diff options
context:
space:
mode:
authorPeter Reid <peter.d.reid@gmail.com>2015-01-17 12:41:18 -0500
committerPeter Reid <peter.d.reid@gmail.com>2015-01-17 12:41:18 -0500
commit2963caf708d722af3411ca83d1536f48a24eabc0 (patch)
tree0ecb125c21478ee7c347278e067c7b4eb27ead11 /components/script/textinput.rs
parent2a9acdcb73685f2c5c14b51f33b741690b60cb23 (diff)
downloadservo-2963caf708d722af3411ca83d1536f48a24eabc0.tar.gz
servo-2963caf708d722af3411ca83d1536f48a24eabc0.zip
Fix TextInput's edit point after set_content
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.
Diffstat (limited to 'components/script/textinput.rs')
-rw-r--r--components/script/textinput.rs11
1 files changed, 2 insertions, 9 deletions
diff --git a/components/script/textinput.rs b/components/script/textinput.rs
index 809fc56de2d..15dc23d677b 100644
--- a/components/script/textinput.rs
+++ b/components/script/textinput.rs
@@ -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);
}