Fix extra blank lines in copied review comment diffs#44
Merged
cpojer merged 2 commits intoJun 3, 2026
Conversation
Copied review comments were reusing parser line text that already included source line endings, then adding Markdown row separators on top. Normalize parser line text at the copied-comment boundary so copied diff blocks stay compact and readable.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR normalizes diff patch line text to avoid double line breaks in generated review comment markdown, and adds a regression test to ensure multi-line ranges render without blank lines.
Changes:
- Strip trailing line terminators from
@pierre/diffspatch lines before formatting markdown. - Centralize patch-line retrieval via a helper to keep formatting consistent.
- Add a test assertion covering adjacency/no-extra-blank-line behavior for multi-line ranges.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/lib/review-comments.ts | Normalizes patch line text when building review comment patch context to prevent extra newlines. |
| src/tests/App.test.tsx | Adds a regression test to verify consecutive patch lines don’t gain an extra blank line in markdown. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+143
to
+146
| // @pierre/diffs keeps source line terminators; copied Markdown rows add their own separators. | ||
| const normalizeReviewPatchText = (line: string) => line.replace(/\r?\n$/, ''); | ||
| const getReviewPatchText = (lines: ReadonlyArray<string>, index: number) => | ||
| normalizeReviewPatchText(lines[index] ?? ''); |
Contributor
Author
There was a problem hiding this comment.
updated this so line endings are trimmed only when formatting the final copied context, not while walking every patch row. Still storing line references on rows, but it’s clear, cheap, and not a blocker here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Copied review comments could add an empty line between each line in the
included diff block.
Codiff now normalizes diff line text before building the copied Markdown, so
the copied diff block uses one newline between rows.
Example
Before:
After:
For a copied review comment, this keeps the Markdown compact and readable:
Validation
pnpm exec vp test src/__tests__/App.test.tsx -t 'review comment markdown'pnpm exec vp check --fixpnpm exec vp build