Fix another crash on empty files

Git history with file additions/removals should now work.
pull/25/head
Wilfred Hughes 2021-07-20 00:22:01 +07:00
parent 9711cdf94e
commit 2d9efe15a0
2 changed files with 3 additions and 2 deletions

@ -3,7 +3,7 @@
### Parsing
Fixed a crash on parsing non-ASCII source files. Fixed a crash on
files without an extension.
files without an extension. Fixed crashes on empty files.
Improved parsing for Rust punctuation.

@ -712,7 +712,8 @@ pub fn aligned_lines(
rhs_lines: &[LineNumber],
lhs_line_matches: &HashMap<LineNumber, LineNumber>,
) -> Vec<(Option<LineNumber>, Option<LineNumber>)> {
let mut rhs_highest_matched = rhs_lines.first().unwrap().number as isize - 1;
let mut rhs_highest_matched = rhs_lines.first().map(|l| l.number as isize).unwrap_or(0) - 1;
// For every LHS line, if there is a RHS line that is included in
// `rhs_lines` and hasn't yet been paired up, add it to
// matched_lines.