Pick up the proper initial index and test
This commit is contained in:
parent
7b2514a610
commit
819b800cf9
1 changed files with 2 additions and 1 deletions
|
|
@ -500,7 +500,7 @@ fn line_range(text: &[u8], index: usize, max_line_len: usize) -> Range<usize> {
|
|||
fn trim_start(text: &[u8], r: Range<usize>) -> Range<usize> {
|
||||
for (index, c) in text[r.start..r.end].iter().enumerate() {
|
||||
if !c.is_ascii_whitespace(){
|
||||
return index..r.end
|
||||
return (r.start+index)..r.end
|
||||
}
|
||||
}
|
||||
return r
|
||||
|
|
@ -530,5 +530,6 @@ mod tests {
|
|||
|
||||
let text = b"\t func foo\nbar\n";
|
||||
assert_eq!(line_range(text, 0, 10), 2..10);
|
||||
assert_eq!(line_range(text, 11, 10), 11..14);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue