Skip to content

Commit

Permalink
fix: out of bounds when rhs line numbers does not match
Browse files Browse the repository at this point in the history
This is caused by the same problem as before, but the disagreement
seems to be with the Tree itself and happens inside
`syntax::change_positions`, there may be another way to work around
this by removing the correct entry from `rhs_positions` when
the conditions are met.
  • Loading branch information
JonathanxD committed Jul 8, 2024
1 parent 9fae982 commit ab39730
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/display/side_by_side.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,14 +515,16 @@ pub(crate) fn print(
None => vec![" ".repeat(source_dims.content_width)],
};
let rhs_line = match rhs_line_num {
Some(rhs_line_num) => split_and_apply(
rhs_lines[rhs_line_num.as_usize()],
source_dims.content_width,
display_options.tab_width,
rhs_highlights.get(rhs_line_num).unwrap_or(&vec![]),
Side::Right,
),
None => vec!["".into()],
Some(rhs_line_num) if rhs_line_num.as_usize() < rhs_lines.len() => {
split_and_apply(
rhs_lines[rhs_line_num.as_usize()],
source_dims.content_width,
display_options.tab_width,
rhs_highlights.get(rhs_line_num).unwrap_or(&vec![]),
Side::Right,
)
}
_ => vec!["".into()],
};

for (i, (lhs_line, rhs_line)) in zip_pad_shorter(&lhs_line, &rhs_line)
Expand Down

0 comments on commit ab39730

Please sign in to comment.