diff-lcs icon indicating copy to clipboard operation
diff-lcs copied to clipboard

ldiff unified/context outputs do not always include trailing context lines

Open Math2 opened this issue 10 months ago • 0 comments

$ 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.

Math2 avatar Apr 12 '24 08:04 Math2