Skip to content

Fix extra blank lines in copied review comment diffs#44

Merged
cpojer merged 2 commits into
nkzw-tech:mainfrom
gumadeiras:codex/fix-copied-review-diff-spacing
Jun 3, 2026
Merged

Fix extra blank lines in copied review comment diffs#44
cpojer merged 2 commits into
nkzw-tech:mainfrom
gumadeiras:codex/fix-copied-review-diff-spacing

Conversation

@gumadeiras
Copy link
Copy Markdown
Contributor

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:

+ 589 | const first = true;

+ 590 | const second = true;

+ 591 | const third = true;

After:

+ 589 | const first = true;
+ 590 | const second = true;
+ 591 | const third = true;

For a copied review comment, this keeps the Markdown compact and readable:

@@ -585,8 +585,10 @@
 587/587 |   expect(markdown).toContain('+   1 | const first = true;');
 588/588 |   expect(markdown).toContain('+   2 | const second = true;');
+ 589 |   expect(markdown).toContain('+   1 | const first = true;\n   +   2 | const second = true;');
+ 590 |   expect(markdown).not.toContain('const first = true;\n\n   +');

Validation

  • pnpm exec vp test src/__tests__/App.test.tsx -t 'review comment markdown'
  • pnpm exec vp check --fix
  • pnpm exec vp build

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.
Copilot AI review requested due to automatic review settings June 2, 2026 23:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/diffs patch 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 thread src/lib/review-comments.ts Outdated
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] ?? '');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

@cpojer cpojer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@cpojer cpojer merged commit 06da997 into nkzw-tech:main Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants