fix: ファイル末尾の改行が常に差分として表示される問題を修正#149
Merged
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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 相当の末尾改行を含む入力での表示を検証し、追加ケースをカバー |
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>
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.
概要
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.luaFudeReviewDiffを実行し、末尾に余分な改行差分が表示されないことを確認Generated with Claude Code