mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Fix off-by-one errors in whitespace-word clumping.
This commit is contained in:
parent
5e5844a33d
commit
c32b74eb63
1 changed files with 6 additions and 6 deletions
|
@ -138,13 +138,13 @@ impl TextRun : TextRunMethods {
|
||||||
// clump contiguous non-whitespace
|
// clump contiguous non-whitespace
|
||||||
match str::find_from(text, clump_start, |c| !char::is_whitespace(c)) {
|
match str::find_from(text, clump_start, |c| !char::is_whitespace(c)) {
|
||||||
Some(clump_end) => {
|
Some(clump_end) => {
|
||||||
if !f(clump_start, clump_end - clump_start + 1) { break }
|
if !f(clump_start, clump_end - clump_start) { break }
|
||||||
clump_start = clump_end + 1;
|
clump_start = clump_end;
|
||||||
// reached end
|
// reached end
|
||||||
if clump_start == offset + length { break }
|
if clump_start == offset + length { break }
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
// nothing left, flush last piece containing only spaces
|
// nothing left, flush last piece containing only whitespace
|
||||||
if clump_start < offset + length {
|
if clump_start < offset + length {
|
||||||
let clump_end = offset + length - 1;
|
let clump_end = offset + length - 1;
|
||||||
f(clump_start, clump_end - clump_start + 1);
|
f(clump_start, clump_end - clump_start + 1);
|
||||||
|
@ -156,13 +156,13 @@ impl TextRun : TextRunMethods {
|
||||||
// clump contiguous whitespace
|
// clump contiguous whitespace
|
||||||
match str::find_from(text, clump_start, |c| char::is_whitespace(c)) {
|
match str::find_from(text, clump_start, |c| char::is_whitespace(c)) {
|
||||||
Some(clump_end) => {
|
Some(clump_end) => {
|
||||||
if !f(clump_start, clump_end - clump_start + 1) { break }
|
if !f(clump_start, clump_end - clump_start) { break }
|
||||||
clump_start = clump_end + 1;
|
clump_start = clump_end;
|
||||||
// reached end
|
// reached end
|
||||||
if clump_start == offset + length { break }
|
if clump_start == offset + length { break }
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// nothing left, flush last piece containing only spaces
|
// nothing left, flush last piece containing only non-whitespaces
|
||||||
if clump_start < offset + length {
|
if clump_start < offset + length {
|
||||||
let clump_end = offset + length - 1;
|
let clump_end = offset + length - 1;
|
||||||
f(clump_start, clump_end - clump_start + 1);
|
f(clump_start, clump_end - clump_start + 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue