diff --git a/src/gh_range_diff.rs b/src/gh_range_diff.rs index 9ff59798..a7984897 100644 --- a/src/gh_range_diff.rs +++ b/src/gh_range_diff.rs @@ -564,6 +564,13 @@ impl UnifiedDiffPrinter for HtmlDiffPrinter<'_> { )?; } + // Add potentially missing new-line after the last before diff line + if let Some(&last) = before.last() { + if !self.0[last].ends_with('\n') { + writeln!(f)?; + } + } + // Then process all after lines for (diff, input) in &diffs_and_inputs { self.handle_hunk_line( @@ -574,6 +581,13 @@ impl UnifiedDiffPrinter for HtmlDiffPrinter<'_> { }), )?; } + + // Add potentially missing new-line after the last after diff line + if let Some(&last) = after.last() { + if !self.0[last].ends_with('\n') { + writeln!(f)?; + } + } } else { // Can't do word-highlighting, simply print each line.