Repository navigation
fix(diff): mark a missing final newline wherever the last line appears - #108
Conversation
Only a change that was nothing but the final newline carried git's `\ No newline at end of file`; any file with other edits lost it, and a last line that gained or lost its newline beside them showed as unchanged. The last line of a side with no newline now compares unequal to a terminated one, so it diffs the way git's does, and the marker follows it as context, deletion or addition, rewrites included. The `<diff>` renderable draws no row for the marker, so `paneLines` no longer gives it one: the slot put every row after it off by one, and the misplaced syntax colour cut the next line short.
|
@TonyWu2333 is attempting to deploy a commit to the letstri Team on Vercel. A member of the Team first needs to authorize it. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
💤 Files with no reviewable changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughDiff generation now marks unterminated final lines in context, deletion, and addition rows. The diff view excludes the marker from pane rows. Tests cover patch content and inline and side-by-side rendering. ChangesFinal newline diff handling
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue is established; the change is ready for normal merge checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
Summary
IMPROVEMENTS.md, "Diffs lose 'no newline at end of file'". Before this, only a change that was nothing but the final newline got git's\ No newline at end of file(vianewlineOnlyDiff). A file with other edits too lost the marker, and if its last line gained or lost a newline next to those edits, the diff showed that line as unchanged.unifiedDiffnow compares the last line of a side without a final newline as unequal to a terminated line. It only changes the comparison keys; the lines it shows are untouched. That makes the Myers/rewrite paths treat the last line the way git does, and the marker now follows that line whether it's context, a deletion or an addition, rewrites included.newlineOnlyDiffisn't needed any more, so it's removed. The marker still doesn't count towardlines.paneLines(DiffView.tsx) no longer gives the marker a slot. OpenTUI 0.5.11's<diff>renderable draws no row for a\line:buildUnifiedViewhas no branch for it, andbuildSplitViewdoesi++. So the extra slot pushed every ref after it down by one, and the misplaced syntax colour cut the next row short (+ const three =instead of+ const three = 3). The new UI test catches that.IMPROVEMENTS.md.For patch bodies from the first
@@on, I checked the output againstgit diff --no-indexon a dozen EOF cases: gained/lost newline, only-context, added last line, emptied file, new file without a newline, far-apart hunks. Every hunk body matched git line for line. The only differences were header details that are the same as before this change (git's-1vs our-1,1, and git's function-context suffix after@@).Test plan
bun test test/diff.test.ts: 4 new cases (other edits plus a gained newline, as an exact patch; unterminated last line as context; an added unterminated line; the rewrite path). All 4 fail onmainand pass here.bun test test/diff-view.test.tsx: new case "the rows after a missing final newline are drawn whole, in either layout". It fails with the oldpaneLinesand passes here.bun run check: types, lint and format are clean. All diff/changes suites pass. In the parallel run, a few git-status UI files (git-footer,git-discard-ui, and on one rununit,git-panel,goto,statusbar) failed on timing, and they fail the same way on unmodifiedmain. Each of them passes when run on its own, on this branch and onmain.-/+with the marker in the patch, and no row after it should be cut.Summary by CodeRabbit