From c32b74eb6370477558508d5711ba614687201e95 Mon Sep 17 00:00:00 2001 From: "Brian J. Burg" Date: Tue, 16 Oct 2012 17:16:28 -0700 Subject: [PATCH] Fix off-by-one errors in whitespace-word clumping. --- src/servo/text/text_run.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/servo/text/text_run.rs b/src/servo/text/text_run.rs index dc42219c65a..1a74db2fcb3 100644 --- a/src/servo/text/text_run.rs +++ b/src/servo/text/text_run.rs @@ -138,13 +138,13 @@ impl TextRun : TextRunMethods { // clump contiguous non-whitespace match str::find_from(text, clump_start, |c| !char::is_whitespace(c)) { Some(clump_end) => { - if !f(clump_start, clump_end - clump_start + 1) { break } - clump_start = clump_end + 1; + if !f(clump_start, clump_end - clump_start) { break } + clump_start = clump_end; // reached end if clump_start == offset + length { break } }, None => { - // nothing left, flush last piece containing only spaces + // nothing left, flush last piece containing only whitespace if clump_start < offset + length { let clump_end = offset + length - 1; f(clump_start, clump_end - clump_start + 1); @@ -156,13 +156,13 @@ impl TextRun : TextRunMethods { // clump contiguous whitespace match str::find_from(text, clump_start, |c| char::is_whitespace(c)) { Some(clump_end) => { - if !f(clump_start, clump_end - clump_start + 1) { break } - clump_start = clump_end + 1; + if !f(clump_start, clump_end - clump_start) { break } + clump_start = clump_end; // reached end if clump_start == offset + length { break } } None => { - // nothing left, flush last piece containing only spaces + // nothing left, flush last piece containing only non-whitespaces if clump_start < offset + length { let clump_end = offset + length - 1; f(clump_start, clump_end - clump_start + 1);