diff-lcs
diff-lcs copied to clipboard
ldiff unified/context outputs do not always include trailing context lines
$ cat > a
123
x
^D
$ cat > b
456
x
^D
$ ldiff -U 3 a b
--- a 2024-04-12 04:32:36.000000000 -0400
+++ b 2024-04-12 04:32:40.000000000 -0400
@@ -1 +1 @@
-123
+456
$ ldiff -C 3 a b
*** a 2024-04-12 04:32:36.000000000 -0400
--- b 2024-04-12 04:32:40.000000000 -0400
***************
*** 1 ****
! 123
--- 1 ----
! 456
The trailing "x" context line isn't there. But if you use "-U 1"/"-C 1", it'll be there.
The problem can be triggered by using Diff::LCS::Hunk directly too (and the amount of context lines you request with Diff::LCS::Hunk#initialize's 4th argument likewise affects if trailing context lines may be missing or not).
The amount of heading context lines for the hunk seem to affect if trailing lines may be missing or not too.