Skip to content

feat: 空白差分の表示/非表示を切り替える FudeReviewToggleWhitespace コマンドの追加#116

Draft
kyu08 wants to merge 1 commit intomainfrom
feat/toggle-iwhite
Draft

feat: 空白差分の表示/非表示を切り替える FudeReviewToggleWhitespace コマンドの追加#116
kyu08 wants to merge 1 commit intomainfrom
feat/toggle-iwhite

Conversation

@kyu08
Copy link
Copy Markdown
Collaborator

@kyu08 kyu08 commented Apr 3, 2026

Summary

  • レビュー中に :FudeReviewToggleWhitespacediffoptiwhite を on/off できるようにした
  • 空白のみの変更が多いファイルで diff のノイズを減らせる
  • レビューモード終了時は original_diffopt の復元により自動クリーンアップされる

Test plan

  • fude を起動し、空白変更のあるファイルで :FudeReviewToggleWhitespace を実行 → diff から空白差分が消えることを確認
  • もう一度実行 → 空白差分が戻ることを確認
  • :FudeReviewStopdiffopt が元に戻ることを確認

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 3, 2026 09:40
Copy link
Copy Markdown
Contributor

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

レビュー中に diffoptiwhite(空白差分無視)をオン/オフできるコマンドを追加し、空白変更が多い差分のノイズを減らせるようにするPRです。レビューセッション停止時に設定が元へ戻ることを前提に、セッション状態 (config.state) にフラグを追加しています。

Changes:

  • :FudeReviewToggleWhitespace コマンドを追加し、iwhite を on/off できるようにした
  • セッション状態に iwhite フラグを追加してトグル状態を保持
  • README / :help / 開発者向けドキュメントにコマンドと状態フィールドを追記

Reviewed changes

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

Show a summary per file
File Description
README.md コマンド一覧に :FudeReviewToggleWhitespace を追加
plugin/fude.lua FudeReviewToggleWhitespace ユーザーコマンドを定義
lua/fude/init.lua toggle_iwhite() を追加して diffoptiwhite を切り替え
lua/fude/config.lua config.stateiwhite を追加し、reset_state() でも初期化
doc/fude.txt :FudeReviewToggleWhitespace のヘルプを追加
CLAUDE.md state フィールド一覧に iwhite を追記

Comment on lines +720 to +726
if state.iwhite then
state.iwhite = false
vim.opt.diffopt:remove("iwhite")
vim.notify("fude.nvim: Whitespace diff ON", vim.log.levels.INFO)
else
state.iwhite = true
vim.opt.diffopt:append("iwhite")
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

state.iwhite の初期値が常に false のため、ユーザーの元の diffopt に既に iwhite が入っているケースでトグル挙動が破綻します(1回目の実行で何も変わらず、2回目でユーザー設定の iwhite を削除してしまう)。トグルは vim.o.diffopt(または vim.opt.diffopt:get())の現在値から実状態を判定して state.iwhite を同期するか、セッション開始時点の diffopt を基準に on/off するようにしてください。

Suggested change
if state.iwhite then
state.iwhite = false
vim.opt.diffopt:remove("iwhite")
vim.notify("fude.nvim: Whitespace diff ON", vim.log.levels.INFO)
else
state.iwhite = true
vim.opt.diffopt:append("iwhite")
local diffopt = vim.opt.diffopt:get()
local has_iwhite = false
for _, opt in ipairs(diffopt) do
if opt == "iwhite" then
has_iwhite = true
break
end
end
-- Sync internal state with the actual current diffopt value before toggling.
state.iwhite = has_iwhite
if has_iwhite then
vim.opt.diffopt:remove("iwhite")
state.iwhite = false
vim.notify("fude.nvim: Whitespace diff ON", vim.log.levels.INFO)
else
vim.opt.diffopt:append("iwhite")
state.iwhite = true

Copilot uses AI. Check for mistakes.
Comment on lines +713 to +718
function M.toggle_iwhite()
local state = config.state
if not state.active then
vim.notify("fude.nvim: Not active", vim.log.levels.WARN)
return
end
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

この実装だと config.opts.diffopt = nil(ユーザー既定の diffopt を維持する設定)の場合に state.original_diffopt が保存されないため、toggle_iwhite() による diffopt 変更が :FudeReviewStop で復元されずに残ります。toggle_iwhite() 実行前(または review start 時)に必ず original_diffopt を退避するようにして、停止時に確実に元へ戻るようにしてください。

Copilot uses AI. Check for mistakes.
Comment on lines +711 to +729
--- Toggle whitespace diff ignore (iwhite).
--- When enabled, whitespace-only changes are hidden from the diff view.
function M.toggle_iwhite()
local state = config.state
if not state.active then
vim.notify("fude.nvim: Not active", vim.log.levels.WARN)
return
end

if state.iwhite then
state.iwhite = false
vim.opt.diffopt:remove("iwhite")
vim.notify("fude.nvim: Whitespace diff ON", vim.log.levels.INFO)
else
state.iwhite = true
vim.opt.diffopt:append("iwhite")
vim.notify("fude.nvim: Whitespace diff ignored", vim.log.levels.INFO)
end
end
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

toggle_iwhite() の追加に対するテストが見当たりません。diffopt の変更/復元(特に stop 時に元へ戻ること、既に iwhite が入っている初期状態でのトグル挙動)を tests/fude/init_integration_spec.lua 等でカバーするテストを追加してください。

Copilot generated this review using guidance from repository custom instructions.
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.

2 participants