Fix off-by-one that breaks empty positions at file beginning

ida_star
Wilfred Hughes 2021-08-12 18:21:27 +07:00
parent 997a2cfb8e
commit 70ee1b736e
1 changed files with 15 additions and 1 deletions

@ -366,7 +366,7 @@ impl NewlinePositions {
if region_start > line_end {
continue;
}
if *line_start >= region_end {
if *line_start > region_end {
break;
}
@ -480,6 +480,20 @@ mod tests {
);
}
#[test]
fn from_ranges_first_char() {
let newline_positions: NewlinePositions = "foo".into();
let line_spans = newline_positions.from_offsets(0, 0);
assert_eq!(
line_spans,
vec![SingleLineSpan {
line: 0.into(),
start_col: 0,
end_col: 0
}]
);
}
#[test]
fn test_visible_groups_ignores_unchanged() {
let lhs_positions = vec![MatchedPos {