Skip to content

fix: ファイル末尾の改行が常に差分として表示される問題を修正#149

Merged
kyu08 merged 3 commits into
mainfrom
fix/preview-trailing-newline
Jun 16, 2026
Merged

fix: ファイル末尾の改行が常に差分として表示される問題を修正#149
kyu08 merged 3 commits into
mainfrom
fix/preview-trailing-newline

Conversation

@kyu08

@kyu08 kyu08 commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

概要

FudeReviewDiff のプレビューバッファで、ファイル末尾の改行が常に差分として表示される問題を修正した。git show の出力に含まれるPOSIX末尾改行を vim.split の前に除去することで、Neovimのバッファ表現と一致させた。

Closes #101

変更内容

  • preview.lua: vim.split の前に末尾の \n を1つだけ除去するガードを追加
  • preview_integration_spec.lua: モック内容を実際の git show 出力に合わせて末尾改行付きに変更し、行数アサーションと末尾改行なしケースのテストを追加

テスト計画

  • 既存テスト全パス (make all)
  • 新規テスト追加: tests/fude/preview_integration_spec.lua
  • 手動確認: 実際のPR上で FudeReviewDiff を実行し、末尾に余分な改行差分が表示されないことを確認

Generated with Claude Code

kyu08 and others added 2 commits June 16, 2026 17:50
git show output includes a POSIX trailing newline, which vim.split
turns into an extra empty line. Neovim buffers don't represent the
file-terminating newline as a line, so the preview always showed a
spurious diff at the end of every file.

Strip exactly one trailing \n before splitting to match Neovim's
buffer representation.

Closes #101

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update mock content to include a trailing newline matching real
git show output. Add line count assertion and a dedicated test
for content without a trailing newline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 16, 2026 08:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

FudeReviewDiff のプレビューバッファで「ファイル末尾の改行が常に差分として出る」問題を、git show 出力と Neovim バッファの行表現差を埋めることで解消するPRです(末尾 \n の扱いと、それに対応する統合テスト更新)。

Changes:

  • preview.lua: vim.split 前に git show 出力の末尾改行を除去する処理を追加
  • preview_integration_spec.lua: モックを末尾改行付きに揃え、行数アサーションと末尾改行なしケースのテストを追加

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lua/fude/preview.lua git show 出力の末尾改行を調整してプレビュー表示の余計な差分を抑制
tests/fude/preview_integration_spec.lua git show 相当の末尾改行を含む入力での表示を検証し、追加ケースをカバー

Comment thread lua/fude/preview.lua
Comment thread tests/fude/preview_integration_spec.lua
Verify that a file ending with multiple newlines (e.g. "line 1\n\n")
correctly preserves the trailing blank line in the preview buffer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kyu08 kyu08 marked this pull request as ready for review June 16, 2026 09:08
Copilot AI review requested due to automatic review settings June 16, 2026 09:08
@kyu08 kyu08 requested a review from flexphere as a code owner June 16, 2026 09:08
@kyu08 kyu08 merged commit 87455d3 into main Jun 16, 2026
17 of 19 checks passed
@kyu08 kyu08 deleted the fix/preview-trailing-newline branch June 16, 2026 09:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

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.

FudeReviewDiff: ファイル末尾の改行が常に差分として表示されてしまう

2 participants