Skip to content

Commit fb369ce

Browse files
authored
Merge pull request #2222 from Urgau/gh-range-diff-missing-newlines
Add missing newlines when doing word-highlighting in our range-diff
2 parents ca1fec9 + 3801852 commit fb369ce

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/gh_range_diff.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,13 @@ impl UnifiedDiffPrinter for HtmlDiffPrinter<'_> {
564564
)?;
565565
}
566566

567+
// Add potentially missing new-line after the last before diff line
568+
if let Some(&last) = before.last() {
569+
if !self.0[last].ends_with('\n') {
570+
writeln!(f)?;
571+
}
572+
}
573+
567574
// Then process all after lines
568575
for (diff, input) in &diffs_and_inputs {
569576
self.handle_hunk_line(
@@ -574,6 +581,13 @@ impl UnifiedDiffPrinter for HtmlDiffPrinter<'_> {
574581
}),
575582
)?;
576583
}
584+
585+
// Add potentially missing new-line after the last after diff line
586+
if let Some(&last) = after.last() {
587+
if !self.0[last].ends_with('\n') {
588+
writeln!(f)?;
589+
}
590+
}
577591
} else {
578592
// Can't do word-highlighting, simply print each line.
579593

0 commit comments

Comments
 (0)