Auto merge of #25485 - teapotd:textinput-maxlength-del, r=nox

Allow deletions from overflowed textinput

Allow deletions from textinput when the length is greater than the max length.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #25420
- [X] There are tests for these changes
This commit is contained in:
bors-servo 2020-01-16 10:49:42 -05:00 committed by GitHub
commit 5c202ed392
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 6 deletions

View file

@ -450,12 +450,6 @@ impl<T: ClipboardProvider> TextInput<T> {
let allowed_to_insert_count = if let Some(max_length) = self.max_length {
let len_after_selection_replaced =
self.utf16_len().saturating_sub(self.selection_utf16_len());
if len_after_selection_replaced >= max_length {
// If, after deleting the selection, the len is still greater than the max
// length, then don't delete/insert anything
return;
}
max_length.saturating_sub(len_after_selection_replaced)
} else {
UTF16CodeUnits(usize::MAX)