FA-75495 / Text diff and three-way merge / Member archive
End-of-file newline diff: a terminated file gains an empty unterminated last line · case 05
Every newline-terminated file shows a phantom empty line with a missing-newline marker.
Case contract
Split each text on "\n" into [line, terminated] tokens; a final empty piece produces no token, a final non-empty piece is an unterminated token. Diff the token lists with an LCS walk (tokens equal only if text and terminator flag both match, deletions before insertions on ties) and render each op as tag + text, followed by "\ No newline at end of file" after any unterminated token.
Why this case matters
Unified diffs must show a change that only adds or removes the final newline, and mark which side lacks it.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| newline added at end of file | [" a", "-b", "\\ No newline at end of file", "+b", "+", "\\ No newline at end of file"] | [" a", "-b", "\\ No newline at end of file", "+b"] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗