mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
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.
This commit is contained in:
parent
2a9acdcb73
commit
2963caf708
1 changed files with 2 additions and 9 deletions
|
@ -357,13 +357,7 @@ impl TextInput {
|
||||||
vec!(content)
|
vec!(content)
|
||||||
};
|
};
|
||||||
self.edit_point.line = min(self.edit_point.line, self.lines.len() - 1);
|
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());
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +513,6 @@ fn test_textinput_set_content() {
|
||||||
textinput.set_content("de".into_string());
|
textinput.set_content("de".into_string());
|
||||||
assert_eq!(textinput.get_content().as_slice(), "de");
|
assert_eq!(textinput.get_content().as_slice(), "de");
|
||||||
assert_eq!(textinput.edit_point.line, 0);
|
assert_eq!(textinput.edit_point.line, 0);
|
||||||
// FIXME: https://github.com/servo/servo/issues/4622.
|
assert_eq!(textinput.edit_point.index, 2);
|
||||||
assert_eq!(textinput.edit_point.index, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue