Auto merge of #15822 - charlesvdv:unicode-panic, r=emilio

Correct unicode handling for text input

<!-- Please describe your changes on the following line: -->
Allow proprer handling of unicode sequence in text input.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #15819

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15822)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-04-16 15:08:59 -05:00 committed by GitHub
commit e45546edf0
3 changed files with 23 additions and 7 deletions

View file

@ -602,3 +602,13 @@ fn test_textinput_set_selection_with_direction() {
assert_eq!(textinput.selection_begin.unwrap().line, 0);
assert_eq!(textinput.selection_begin.unwrap().index, 6);
}
#[test]
fn test_textinput_unicode_handling() {
let mut textinput = text_input(Lines::Single, "éèùµ$£");
assert_eq!(textinput.edit_point.index, 0);
textinput.set_edit_point_index(1);
assert_eq!(textinput.edit_point.index, 2);
textinput.set_edit_point_index(4);
assert_eq!(textinput.edit_point.index, 8);
}