Skip to content

Commit

Permalink
Fix a range-respecting bug in iter_indivisible_pieces_for_range.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian J. Burg committed Oct 22, 2012
1 parent 1e7c49a commit 538fc9e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/servo/text/text_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ impl TextRun : TextRunMethods {
let clump = MutableRange(range.begin(), 0);
loop {
// find next non-whitespace byte index, then clump all whitespace before it.
if clump.end() == range.end() { break }
match str::find_from(self.text, clump.begin(), |c| !char::is_whitespace(c)) {
match str::find_between(self.text, clump.begin(), range.end(), |c| !char::is_whitespace(c)) {
Some(nonws_char_offset) => {
clump.extend_to(nonws_char_offset);
if !f(clump.as_immutable()) { break }
Expand All @@ -136,13 +135,13 @@ impl TextRun : TextRunMethods {
if clump.end() < range.end() {
clump.extend_to(range.end());
f(clump.as_immutable());
break;
}
}
};

// find next whitespace byte index, then clump all non-whitespace before it.
if clump.end() == range.end() { break }
match str::find_from(self.text, clump.begin(), |c| char::is_whitespace(c)) {
match str::find_between(self.text, clump.begin(), range.end(), |c| char::is_whitespace(c)) {
Some(ws_char_offset) => {
clump.extend_to(ws_char_offset);
if !f(clump.as_immutable()) { break }
Expand All @@ -153,6 +152,7 @@ impl TextRun : TextRunMethods {
if clump.end() < range.end() {
clump.extend_to(range.end());
f(clump.as_immutable());
break;
}
}
}
Expand Down

0 comments on commit 538fc9e

Please sign in to comment.