FA-75502 / Text diff and three-way merge / Member archive
End-of-file newline diff: the marker is written only after removed lines · case 02
An added last line without newline is shown as if it had one.
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 removed at end of file | [" a", "-b", "+b"] | [" a", "-b", "+b", "\\ No newline at end of file"] | 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 ↗